{"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\u003eA graph without loops or multiple edges is known as a simple graph.\u003c/p\u003e\u003cp\u003eA vertex-colouring is an assignment of colours to each vertex of a graph. A proper vertex-colouring is a vertex-colouring in which no edge connects two identically coloured vertices.\u003c/p\u003e\u003cp\u003eA vertex-colouring with $$$n$$$ colours of an undirected simple graph is called an $$$n$$$-rainbow colouring if every colour appears once, and only once, on all the adjacent vertices of each vertex. Note that an $$$n$$$-rainbow colouring is not a proper colouring, since adjacent vertices may share the same colour.\u003c/p\u003e\u003cp\u003eAn undirected simple graph is called an $$$n$$$-rainbow graph if the graph can admit at least one legal $$$n$$$-rainbow colouring. Two $$$n$$$-rainbow graphs $$$G$$$ and $$$H$$$ are called isomorphic if, between the sets of vertices in $$$G$$$ and $$$H$$$, a bijective mapping $$$f: V(G) \\to V(H)$$$ exists such that two vertices in $$$G$$$ are adjacent if and only if their images in $$$H$$$ are adjacent.\u003c/p\u003e\u003cp\u003eYour task in this problem is to count the number of distinct non-isomorphic $$$n$$$-rainbow graphs having $$$2 n$$$ vertices and report that number modulo a prime number $$$p$$$.\u003c/p\u003e"}},{"title":"Input","value":{"format":"HTML","content":"\u003cp\u003eThe input contains several test cases, and the first line contains a positive integer $$$T$$$ indicating the number of test cases which is up to $$$1000$$$.\u003c/p\u003e\u003cp\u003eFor each test case, the only line contains two integers $$$n$$$ and $$$p$$$ where $$$1 \\le n \\le 64$$$, $$$n + 1 \\le p \\le 2^{30}$$$ and $$$p$$$ is a prime.\u003c/p\u003e\u003cp\u003eWe guarantee that the numbers of test cases satisfying $$$n \\ge 16$$$, $$$n \\ge 32$$$ and $$$n \\ge 48$$$ are no larger than $$$200$$$, $$$100$$$ and $$$20$$$ respectively.\u003c/p\u003e"}},{"title":"Output","value":{"format":"HTML","content":"\u003cp\u003eFor each test case, output a line containing \"\u003cspan class\u003d\"tex-font-style-tt\"\u003eCase #x: y\u003c/span\u003e\" (without quotes), where \u003cspan class\u003d\"tex-font-style-tt\"\u003ex\u003c/span\u003e is the test case number starting from $$$1$$$, and \u003cspan class\u003d\"tex-font-style-tt\"\u003ey\u003c/span\u003e is the answer modulo $$$p$$$.\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\n1 11059\n2 729557\n3 1461283\n4 5299739\n63 49121057\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003eCase #1: 1\nCase #2: 1\nCase #3: 2\nCase #4: 3\nCase #5: 5694570\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\u003eIf you came up with a solution such that the time complexity is asymptotic to $$$p(n)$$$, the number of partitions of $$$n$$$, or similar, you might want to know $$$p(16) \u003d 231$$$, $$$p(32) \u003d 8349$$$, $$$p(48) \u003d 147273$$$ and $$$p(64) \u003d 1741630$$$.\u003c/p\u003e\u003cp\u003eThe following figures illustrate all the non-isomorphic rainbow graphs mentioned in the first four sample cases.\u003c/p\u003e\u003ccenter\u003e \u003cimg class\u003d\"tex-graphics\" src\u003d\"CDN_BASE_URL/d134ba3e9a0fdb7bc45fb41aa03fa7c5?v\u003d1715748104\" style\u003d\"max-width: 100.0%;max-height: 100.0%;\"\u003e \u003c/center\u003e"}}]}