Gentle Jena II
时间限制:C/C++/Rust/Pascal 10秒,其他语言20秒
空间限制:C/C++/Rust/Pascal 256 M,其他语言512 M
64bit IO Format: %lld

题目描述

... Why don't you come to the planetarium?

The beautiful twinkling of eternity that will never fade, no matter what.

All the stars in the sky are waiting for you...

A planetarium, it was once where people went to soothe their hearts by gazing at a starry sky.

And Yumemi, a planetarium guide who has been waiting for a visitor for a long time, is looking up at the stars.

The sky can be regarded as a 2-D Cartesian coordinate system. There are stars in the sky, and the position of the -th star is initially.

But the night sky is not always the same. The positions of some stars may change. So you need to help Yumemi handle queries. The -th query is one of the following two:

  1. Stars numbered within rotate counter clockwise around .

  2. Given and , ask for the value of , where indicates the current position of the -th star.


输入描述:

The first line contains two integers  and  ().

The -th of the next  lines contains two integers .
The -th of the next  lines contains five integers  or three integers , which respectively represent two different queries.

输出描述:

Output the answer to the corresponding query  in each line. Note that you need to output the value modulo .
示例1

输入

复制
3 4
1 2
2 1
-3 -3
1 1 3 0 0
2 2 3
1 2 3 100 100
2 1 2

输出

复制
998244351
0