import std; void main () { int K, S, N; readln.read(K, S, N); const int MOD = 10007; auto fib = new int[](N + 1); fib[0] = 1; fib[1] = 1; foreach (i; 2 .. N + 1) { fib[i] = (fib[i - 1] + fib[i - 2]) % MOD; } auto A = new int[](N + 1); A[0] = 0; A[1] = S; foreach (i; 2 .. N + 1) { foreach (k; 0 .. K + 1) { if (i - k - 1 < 0) { break; } A[i] += A[i - k - 1] * mod_inv(fib[k], MOD) % MOD; } A[i] %= MOD; } writeln(A[N]); } void read (T...) (string S, ref T args) { import std.conv : to; import std.array : split; auto buf = S.split; foreach (i, ref arg; args) { arg = buf[i].to!(typeof(arg)); } } long mod_pow (long a, long x, const long MOD) in { assert(0 <= x, "x must satisfy 0 <= x"); assert(1 <= MOD, "MOD must satisfy 1 <= MOD"); assert(MOD <= int.max, "MOD must satisfy MOD*MOD <= long.max"); } do { // normalize a %= MOD; a += MOD; a %= MOD; long res = 1L; long base = a; while (0 < x) { if (0 < (x&1)) (res *= base) %= MOD; (base *= base) %= MOD; x >>= 1; } return res % MOD; } // check mod_pow static assert(__traits(compiles, mod_pow(2, 10, 998244353))); long mod_inv (const long x, const long MOD) in { import std.format : format; assert(1 <= MOD, format("MOD must satisfy 1 <= MOD. Now MOD = %s.", MOD)); assert(MOD <= int.max, format("MOD must satisfy MOD*MOD <= long.max. Now MOD = %s.", MOD)); } do { return mod_pow(x, MOD-2, MOD); }