{"trustable":false,"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":"\u003cscript type\u003d\u0027text/x-mathjax-config\u0027\u003eMathJax.Hub.Config({tex2jax: { inlineMath: [[\u0027$\u0027,\u0027$\u0027]] } }); \u003c/script\u003e\n\u003cscript type\u003d\u0027text/javascript\u0027 src\u003d\u0027https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config\u003dTeX-AMS-MML_HTMLorMML\u0027\u003e\u003c/script\u003e\n\u003cscript type\u003d\u0027text/javascript\u0027\u003esetTimeout(function(){MathJax.Hub.Queue([\u0027Typeset\u0027, MathJax.Hub, \u0027left_view\u0027]);}, 2000);\u003c/script\u003e\n\u003cdiv class\u003d\"panel_content\"\u003e\n 虽然冬天很远,但松鼠们为了拯救豆子不得不日夜工作。他们需要充足的食物来度过那些漫长寒冷的日子。过了一段时间,松鼠一家认为他们必须解决一个问题。他们假设他们将把豆子保存在 n 棵不同的树上。但是,由于现在食物不够,他们只能得到m豆。他们想知道有多少种方法可以在 n 棵树中保存不超过 m 个豆子(它们是相同的)。\n \u003cbr\u003e\n \u003cbr\u003e现在他们向你求助,你应该给他们答案。结果可能非常巨大;你应该输出结果模 p,因为松鼠不能识别大数字。\n\u003c/div\u003e"}},{"title":"Input","value":{"format":"HTML","content":"第一行包含一个整数T,表示病例数。\n\u003cbr\u003e\n\u003cbr\u003e然后是T行,每行包含三个整数n,m,p,表示松鼠在n棵不同的树中最多保存m个相同的豆子,1 \u003c\u003d n, m \u003c\u003d 1000000000, 1 \u003c p \u003c 100000 and p is保证是素数。\n\n"}},{"title":"Output","value":{"format":"HTML","content":"您应该输出模 p 的答案。"}},{"title":"Sample Input","value":{"format":"HTML","content":"\u003cpre\u003e2\n1 2 5\n2 1 5\u003c/pre\u003e"}},{"title":"Sample Output","value":{"format":"HTML","content":"\u003cpre\u003e3\n3\n\n \u003ci style\u003d\"font-size:1px\"\u003e \u003c/i\u003e\u003c/pre\u003e"}},{"title":"Hint","value":{"format":"HTML","content":"\u003cpre\u003e\nHint\n\nFor sample 1, squirrels will put no more than 2 beans in one tree. Since trees are different, we can label them as 1, 2 … and so on. \nThe 3 ways are: put no beans, put 1 bean in tree 1 and put 2 beans in tree 1. For sample 2, the 3 ways are:\n put no beans, put 1 bean in tree 1 and put 1 bean in tree 2.\n\n \u003c/pre\u003e"}}]}