{"trustable":true,"sections":[{"title":"","value":{"format":"MD","content":"You have to find the **n\u003csup\u003eth\u003c/sup\u003e** term of the following function:\n\n$$f(n) \u003d\n\\begin{cases}\na \\times f(n-1) + b \\times f(n-3) + c, \u0026 \\text{if $n$ \u003e 2} \\cr\n0, \u0026 \\text{if $n$ \u0026leq; 2}\n\\end{cases}$$\n"}},{"title":"Input","value":{"format":"MD","content":"Input starts with an integer **T (\u0026le; 100)**, denoting the number of test cases.\n\nEach case contains four integers **n (0 \u0026le; n \u0026le; 10\u003csup\u003e8\u003c/sup\u003e),** **a b c (1 \u0026le; a, b, c \u0026le; 10000)**."}},{"title":"Output","value":{"format":"MD","content":"For each case, print the case number and **f(n)** modulo **10007**."}},{"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\u003e2\n10 1 2 3\n5 1 3 9\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003eCase 1: 162\nCase 2: 27\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}}]}