SP9543 DCES - Dynamic Congruence Equation System

Description

Consider the congruence equation system as the following form: x\[1\] = k1 x\[p1\] + b1 (mod 10007) x\[2\] = k2 x\[p2\] + b2 (mod 10007) ... x\[n\] = kn x\[pn\] + bn (mod 10007) We will ask you to achieve some instructions as the following form: - A i: Ask the current x\[i\]'s value. (or "-1" for no solution, "-2" for multiply solution.) - C i k p b: Modify the ith congruence equation to a new one.

Input Format

The first two lines are N and Q. Than following Q lines are the query above. (.. N

Output Format

For each query, print the result.