Conic Section

아직 제출이 없습니다시간 제한3초메모리 제한256 MB

문제

Rikka generates an integer sequence u_1,u_2,u\_1, u\_2, \ldots as follows: she generates x_1,x_2,x\_1, x\_2, \ldots, where x_i=(100,000,005x_i1+20,150,609)mod998,244,353x\_i = (100\\,000\\,005 \cdot x\_{i - 1} + 20\\,150\\,609) \bmod 998\\,244\\,353, and then sets u_i=x_i100u\_i = \lfloor \frac{x\_i}{100} \rfloor.

Initially, there are nn points on the Cartesian plane. The ii-th point has coordinates (i,u_imod100,001)(i, u\_{i} \bmod 100\\,001). After that, mm operations are performed subsequently. The ii-th operation has one of the three types: "C", "R", and "Q".

Let p_i=minu_n+2i1modn,u_n+2imodn+1p\_i = \min\\{u\_{n + 2i - 1} \bmod n, u\_{n + 2i} \bmod n\\} + 1 and q_i=maxu_n+2i1modn,u_n+2imodn+1q\_i = \max\\{u\_{n + 2i - 1} \bmod n, u\_{n + 2i} \bmod n\\} + 1.

  • If the ii-th operation is of type "C", transform the (u_n+2i1modn+1)(u\_{n + 2i - 1} \bmod n + 1)-th point into (u_n+2i1modn+1,u_n+2imod100,001)(u\_{n + 2i - 1} \bmod n + 1, u\_{n + 2i} \bmod 100\\,001).
  • If the ii-th operation is of type "R", for all xx such that p_ixq_ip\_i \leq x \leq q\_i, transform the point (x,y)(x, y) into (x,100,000y)(x, 100\\,000 - y).
  • If the ii-th operation is of type "Q", consider all currently existing points (x,y)(x, y) such that p_ixq_ip\_i \leq x \leq q\_i and, given a_ia\_i, b_ib\_i and c_ic\_i, find maxa_ix+b_iy+c_ixy\max\\{ a\_{i} \cdot x + b\_{i} \cdot y + c\_{i} \cdot x \cdot y \\}.

입력

The first line contains three integers: nn, mm, and x_0x\_0 (1n1051 \leq n \leq 10^5, 1m1061 \leq m \leq 10^6, 0x_0<998,244,3530 \leq x\_0 < 998\\,244\\,353, x_0340,787,122x\_0 \neq 340\\,787\\,122).

The ii-th of the following mm lines starts with a character t_it\_i, the type of the operation, which is either "C", "R", or "Q". If t_it\_i is "Q", three integers a_i,b_i,c_ia\_i, b\_i, c\_i follow (0a_i,b_i<1060 \leq a\_i, b\_i < 10^6, 0c_i<400 \leq c\_i < 40).

It is guaranteed that the number of operations of type Q does not exceed 10510^5.

출력

For each operation of type "Q", output an integer which denotes the maximum.

힌트

Initially, the three points lie in (1,91263)(1, 91263), (2,33372)(2, 33372) and (3,10601)(3, 10601) respectively.

The first operation changes the third point to (3,94317)(3, 94317).