{"trustable":true,"prependHtml":"\u003cscript\u003e window.katexOptions \u003d { disable: true }; \u003c/script\u003e\n\u003cscript type\u003d\"text/x-mathjax-config\"\u003e\n MathJax.Hub.Config({\n tex2jax: {\n inlineMath: [[\u0027$$$\u0027,\u0027$$$\u0027], [\u0027$\u0027,\u0027$\u0027]],\n displayMath: [[\u0027$$$$$$\u0027,\u0027$$$$$$\u0027], [\u0027$$\u0027,\u0027$$\u0027]]\n }\n });\n\u003c/script\u003e\n\u003cscript async src\u003d\"https://mathjax.codeforces.org/MathJax.js?config\u003dTeX-AMS-MML_HTMLorMML\" type\u003d\"text/javascript\"\u003e\u003c/script\u003e","sections":[{"title":"","value":{"format":"HTML","content":"\u003cdiv class\u003d\"panel_content\"\u003eOne day, a useless calculator was being built by Kuros. Let\u0027s assume that number X is showed on the screen of calculator. At first, X \u003d 1. This calculator only supports two types of operation.\u003cbr\u003e1. multiply X with a number.\u003cbr\u003e2. divide X with a number which was multiplied before.\u003cbr\u003eAfter each operation, please output the number X modulo M.\u003cbr\u003e\u003c/div\u003e"}},{"title":"Input","value":{"format":"HTML","content":"The first line is an integer T($1 \\leq T \\leq 10$), indicating the number of test cases.\u003cbr\u003eFor each test case, the first line are two integers Q and M. Q is the number of operations and M is described above. ($1 \\leq Q \\leq 10^5, 1 \\leq M \\leq 10^9$)\u003cbr\u003eThe next Q lines, each line starts with an integer x indicating the type of operation.\u003cbr\u003eif x is 1, an integer y is given, indicating the number to multiply. ($0 \u0026lt; y \\leq 10^9$)\u003cbr\u003eif x is 2, an integer n is given. The calculator will divide the number which is multiplied in the nth operation. (the nth operation must be a type 1 operation.)\u003cbr\u003e\u003cbr\u003eIt\u0027s guaranteed that in type 2 operation, there won\u0027t be two same n.\u003cbr\u003e"}},{"title":"Output","value":{"format":"HTML","content":"For each test case, the first line, please output \"Case #x:\" and x is the id of the test cases starting from 1.\u003cbr\u003eThen Q lines follow, each line please output an answer showed by the calculator.\u003cbr\u003e"}},{"title":"Sample","value":{"format":"HTML","content":"\u003ctable class\u003d\u0027vjudge_sample\u0027\u003e\n\u003cthead\u003e\n \u003ctr\u003e\n \u003cth\u003eInput\u003c/th\u003e\n \u003cth\u003eOutput\u003c/th\u003e\n \u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n \u003ctr\u003e\n \u003ctd\u003e\u003cpre\u003e1\r\n10 1000000000\r\n1 2\r\n2 1\r\n1 2\r\n1 10\r\n2 3\r\n2 4\r\n1 6\r\n1 7\r\n1 12\r\n2 7\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003eCase #1:\r\n2\r\n1\r\n2\r\n20\r\n10\r\n1\r\n6\r\n42\r\n504\r\n84\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}}]}