{"trustable":false,"sections":[{"title":"","value":{"format":"HTML","content":"\u003cstyle type\u003d\"text/css\"\u003e pre { text-align:left; font-family: \"Courier New\", Courier, monospace; font-size: 16px; white-space: pre; line-height:20px; text-indent: 0px; }\u003c/style\u003e\u003cdiv class\u003d\"pro_desc\"\u003e\n Given a integers x \u003d 1, you have to apply Q (Q ≤ 100000) operations: Multiply, Divide. \n\u003c/div\u003e"}},{"title":"Input","value":{"format":"HTML","content":"\u003cdiv class\u003d\"pro_desc\"\u003e\n \u003cp\u003eFirst line of the input file contains an integer T(0 \u0026lt; T ≤ 10) that indicates how many cases of inputs are there. \u003c/p\u003e\n \u003cp\u003eThe description of each case is given below: \u003c/p\u003e\n \u003cp\u003eThe first line contains two integers Q and M. The next Q lines contains the operations in ith line following form: \u003c/p\u003e\n \u003cp\u003eM yi: x \u003d x * yi. \u003c/p\u003e\n \u003cp\u003eD di: x \u003d x / ydi.\u003c/p\u003e\n \u003cp\u003eIt’s ensure that di is different. That means you can divide yi only once after yi came up.\u003c/p\u003e\n \u003cp\u003e0 \u0026lt; yi ≤ 10^9, M ≤ 10^9 \u003c/p\u003e\n\u003c/div\u003e"}},{"title":"Output","value":{"format":"HTML","content":"\u003cdiv class\u003d\"pro_desc\"\u003e\n \u003cp\u003eFor each operation, print an integer (one per line) x % M. \u003c/p\u003e\n\u003c/div\u003e"}},{"title":"Sample Input","value":{"format":"HTML","content":"\u003cpre\u003e1\n10 1000000000\nM 2\nD 1\nM 2\nM 10\nD 3\nD 4\nM 6\nM 7\nM 12\nD 7\u003c/pre\u003e"}},{"title":"Sample Output","value":{"format":"HTML","content":"\u003cpre\u003e2\n1\n2\n20\n10\n1\n6\n42\n504\n84\u003c/pre\u003e"}}]}