In a kingdom there are N people. The i-th person lives on a point (xi, yi). You are a monster that needs to go around the kingdom and capture all N people.
Your journey will be like this:
You have to process Q queries of 2 types:
In this problem, you will be given integer BASE and multiple queries. You will have to set the initial value T = 0.
Query of type 0 means that the specified person moves to the point ((a1 * T + b1)%BASE, (a2 * T + b2)%BASE).
For query of type 1 you will need to output the minimum time of your journey of capturing all the people, if you would start at the coordinate ((a1 * T + b1)%BASE, (a2 * T + b2)%BASE). You should update the value of T with the calculated time.
In the first line of input there are three integers N, Q and BASE (0 ≤ N, Q ≤ 105, 0 ≤ BASE ≤ 109. In the following N lines there are two integers xi and yi each (0 ≤ xi, yi ≤ BASE) – coordinates of the people.
In the following Q lines there are queries of the following types:
For the every query of type 1 output single integer – the minimal time it would take to complete a journey of capturing all the people – each on separate line.
3 4 1000000000
2 2
3 1
7 0
1 2 4 3 5
0 3 1 1 7 3
1 4 3 2 6
0 2 2 7 4 1
28
728
In the sample test case, you process four queries: