1 #include <cstdio> 2 #include <cstring> 3 #include <algorithm> 4 #include <iostream> 5 #include <vector> 6 using namespace std; 7 typedef long long LL; 8 9 const int MOD = 9999991; 10 const int MAXN = 1010; 11 12 int f[] = {-2, -1, 1, 2}; 13 14 int n, m, k, x0, y0, T; 15 int dpx[MAXN][MAXN], dpy[MAXN][MAXN]; 16 int sumx[MAXN], sumy[MAXN]; 17 int c[MAXN][MAXN]; 18 19 void initc() { 20 int n = 1000; 21 c[0][0] = 1; 22 for(int i = 1; i <= n; ++i) { 23 c[i][0] = 1; 24 for(int j = 1; j <= i; ++j) 25 c[i][j] = (c[i - 1][j] + c[i - 1][j - 1]) % MOD; 26 } 27 } 28 29 bool check(int x, int n) { 30 return 1 <= x && x <= n; 31 } 32 33 int solve() { 34 memset(dpx, 0, sizeof(dpx)); 35 dpx[0][x0] = 1; 36 for(int p = 1; p <= k; ++p) { 37 for(int i = 1; i <= n; ++i) { 38 for(int v = 0; v < 4; ++v) { 39 int t = i + f[v]; 40 if(check(t, n)) dpx[p][t] = (dpx[p][t] + dpx[p - 1][i]) % MOD; 41 } 42 } 43 } 44 45 memset(sumx, 0, sizeof(sumx)); 46 for(int i = 0; i <= k; ++i) { 47 for(int j = 1; j <= n; ++j) sumx[i] = (sumx[i] + dpx[i][j]) % MOD; 48 } 49 50 memset(dpy, 0, sizeof(dpy)); 51 dpy[0][y0] = 1; 52 for(int p = 1; p <= k; ++p) { 53 for(int i = 1; i <= m; ++i) { 54 for(int v = 0; v < 4; ++v) { 55 int t = i + f[v]; 56 if(check(t, m)) dpy[p][t] = (dpy[p][t] + dpy[p - 1][i]) % MOD; 57 } 58 } 59 } 60 61 memset(sumy, 0, sizeof(sumy)); 62 for(int i = 0; i <= k; ++i) { 63 for(int j = 1; j <= m; ++j) sumy[i] = (sumy[i] + dpy[i][j]) % MOD; 64 } 65 66 LL ans = 0; 67 for(int i = 0; i <= k; ++i) 68 ans = (ans + LL(c[k][i]) * sumx[i] % MOD * sumy[k - i]) % MOD; 69 70 return (int)ans; 71 } 72 73 int main() { 74 initc(); 75 //cout<<c[1000][1000]<<endl; 76 scanf("%d", &T); 77 for(int t = 1; t <= T; ++t) { 78 scanf("%d%d%d%d%d", &n, &m, &k, &x0, &y0); 79 printf("Case #%d:\n", t); 80 printf("%d\n", solve()); 81 } 82 }