{"trustable":false,"sections":[{"title":"","value":{"format":"MD","content":"You have to find the **n\u003csup\u003eth\u003c/sup\u003e** term of the following function:\n\nIf \u003cb\u003e n\u003c\u003d2 \u003c/b\u003e, \u003cb\u003e f(n) \u003d 0 \u003c/b\u003e\u003c/br\u003e\nelse \u003cb\u003e f(n) \u003d a * f(n-1) + b * f(n-3) + c \u003c/b\u003e\u003c/br\u003e"}},{"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":"MD","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"}}]}