{"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\"\u003eThere are $m$ stones lying on a circle, and $n$ frogs are jumping over them.\u003cbr\u003eThe stones are numbered from $0$ to $m-1$ and the frogs are numbered from $1$ to $n$. The $i$-th frog can jump over exactly $a_i$ stones in a single step, which means from stone $j~mod~m$ to stone $(j+a_i)~mod~m$ (since all stones lie on a circle).\u003cbr\u003e\u003cbr\u003eAll frogs start their jump at stone $0$, then each of them can jump as many steps as he wants. A frog will occupy a stone when he reach it, and he will keep jumping to occupy as much stones as possible. A stone is still considered ``occupied\" after a frog jumped away.\u003cbr\u003eThey would like to know which stones can be occupied by at least one of them. Since there may be too many stones, the frogs only want to know the sum of those stones\u0027 identifiers.\u003c/div\u003e"}},{"title":"Input","value":{"format":"HTML","content":"There are multiple test cases (no more than $20$), and the first line contains an integer $t$,\u003cbr\u003emeaning the total number of test cases.\u003cbr\u003e\u003cbr\u003eFor each test case, the first line contains two positive integer $n$ and $m$ - the number of frogs and stones respectively $(1\\le n\\le 10^4,~1\\le m\\le 10^9)$.\u003cbr\u003e\u003cbr\u003eThe second line contains $n$ integers $a_1,a_2,\\cdots,a_n$, where $a_i$ denotes step length of the $i$-th frog $(1\\le a_i\\le 10^9)$."}},{"title":"Output","value":{"format":"HTML","content":"For each test case, you should print first the identifier of the test case and then the sum of all occupied stones\u0027 identifiers."}},{"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\u003e3\r\n2 12\r\n9 10\r\n3 60\r\n22 33 66\r\n9 96\r\n81 40 48 32 64 16 96 42 72\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003eCase #1: 42\r\nCase #2: 1170\r\nCase #3: 1872\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}}]}