{"trustable":true,"prependHtml":"\u003cstyle type\u003d\u0027text/css\u0027\u003e\n .input, .output {\n border: 1px solid #888888;\n }\n .output {\n margin-bottom: 1em;\n position: relative;\n top: -1px;\n }\n .output pre, .input pre {\n background-color: #EFEFEF;\n line-height: 1.25em;\n margin: 0;\n padding: 0.25em;\n }\n \u003c/style\u003e\n \u003clink rel\u003d\"stylesheet\" href\u003d\"//codeforces.org/s/96598/css/problem-statement.css\" type\u003d\"text/css\" /\u003e\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 type\u003d\"text/javascript\" async src\u003d\"https://mathjax.codeforces.org/MathJax.js?config\u003dTeX-AMS_HTML-full\"\u003e\u003c/script\u003e","sections":[{"title":"","value":{"format":"HTML","content":"\u003cp\u003eSuppose you are performing the following algorithm. There is an array $$$v_1, v_2, \\dots, v_n$$$ filled with zeroes at start. The following operation is applied to the array several times — at $$$i$$$-th step ($$$0$$$-indexed) you can: \u003c/p\u003e\u003cul\u003e \u003cli\u003e either choose position $$$pos$$$ ($$$1 \\le pos \\le n$$$) and increase $$$v_{pos}$$$ by $$$k^i$$$; \u003c/li\u003e\u003cli\u003e or not choose any position and skip this step. \u003c/li\u003e\u003c/ul\u003e\u003cp\u003eYou can choose how the algorithm would behave on each step and when to stop it. The question is: can you make array $$$v$$$ equal to the given array $$$a$$$ ($$$v_j \u003d a_j$$$ for each $$$j$$$) after some step?\u003c/p\u003e"}},{"title":"Input","value":{"format":"HTML","content":"\u003cp\u003eThe first line contains one integer $$$T$$$ ($$$1 \\le T \\le 1000$$$) — the number of test cases. Next $$$2T$$$ lines contain test cases — two lines per test case.\u003c/p\u003e\u003cp\u003eThe first line of each test case contains two integers $$$n$$$ and $$$k$$$ ($$$1 \\le n \\le 30$$$, $$$2 \\le k \\le 100$$$) — the size of arrays $$$v$$$ and $$$a$$$ and value $$$k$$$ used in the algorithm.\u003c/p\u003e\u003cp\u003eThe second line contains $$$n$$$ integers $$$a_1, a_2, \\dots, a_n$$$ ($$$0 \\le a_i \\le 10^{16}$$$) — the array you\u0027d like to achieve.\u003c/p\u003e"}},{"title":"Output","value":{"format":"HTML","content":"\u003cp\u003eFor each test case print \u003cspan class\u003d\"tex-font-style-tt\"\u003eYES\u003c/span\u003e (case insensitive) if you can achieve the array $$$a$$$ after some step or \u003cspan class\u003d\"tex-font-style-tt\"\u003eNO\u003c/span\u003e (case insensitive) otherwise.\u003c/p\u003e"}},{"title":"Examples","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\u003e5\n4 100\n0 0 0 0\n1 2\n1\n3 4\n1 4 1\n3 2\n0 1 3\n3 9\n0 59049 810\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003eYES\nYES\nNO\nNO\nYES\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}},{"title":"Note","value":{"format":"HTML","content":"\u003cp\u003eIn the first test case, you can stop the algorithm before the $$$0$$$-th step, or don\u0027t choose any position several times and stop the algorithm.\u003c/p\u003e\u003cp\u003eIn the second test case, you can add $$$k^0$$$ to $$$v_1$$$ and stop the algorithm.\u003c/p\u003e\u003cp\u003eIn the third test case, you can\u0027t make two $$$1$$$ in the array $$$v$$$.\u003c/p\u003e\u003cp\u003eIn the fifth test case, you can skip $$$9^0$$$ and $$$9^1$$$, then add $$$9^2$$$ and $$$9^3$$$ to $$$v_3$$$, skip $$$9^4$$$ and finally, add $$$9^5$$$ to $$$v_2$$$.\u003c/p\u003e"}}]}