{"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\"\u003eAs an exciting puzzle game for kids and girlfriends, the Matches Puzzle Game asks the player to find the number of possible equations $A - B \u003d C$ with exactly $n~(5\\le n\\le 500)$ matches (or sticks).\u003cbr\u003e\u003ccenter\u003e\u003cimg style\u003d\"max-width:100%;\" src\u003d\"CDN_BASE_URL/5bdc7280f749182f8094769c645b42e3?v\u003d1715215582\"\u003e\u003c/center\u003e \u003cbr\u003eIn these equations, $A,B$ and $C$ are positive integers. The equality sign needs two matches and the sign of subtraction needs just one. Leading zeros are not allowed.\u003cbr\u003e\u003ccenter\u003e\u003cimg style\u003d\"max-width:100%;\" src\u003d\"CDN_BASE_URL/ffc014fa6248888d2c80b6a2e1bd5cd0?v\u003d1715215582\"\u003e\u003c/center\u003e \u003cbr\u003ePlease answer the number, modulo a given integer $m~(3\\le m\\le 2\\times 10^9)$.\u003cbr\u003e\u003c/div\u003e"}},{"title":"Input","value":{"format":"HTML","content":"The input contains several test cases. The first line of the input is a single integer $t$ which is the number of test cases. Then $t~(1\\le t\\le 30)$ test cases follow.\u003cbr\u003e\u003cbr\u003eEach test case contains one line with two integers $n~(5\\le n\\le 500)$ and $m~(3\\le m\\le 2\\times 10^9)$."}},{"title":"Output","value":{"format":"HTML","content":"For each test case, you should output the answer modulo $m$.\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\u003e4\r\n12 1000000007\r\n17 1000000007\r\n20 1000000007\r\n147 1000000007\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003eCase #1: 1\r\nCase #2: 5\r\nCase #3: 38\r\nCase #4: 815630825\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}}]}