// iostream is too mainstream
#include <cstdio>
// bitch please
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <iomanip>
#define dibs reserve
#define OVER9000 1234567890
#define patkan 9
#define tisic 47
#define soclose 10e-7
#define ALL_THE(CAKE,LIE) for(auto LIE =CAKE.begin(); LIE != CAKE.end(); LIE++)
#define chocolate win
#define ff first
#define ss second
#define abs(x) ((x < 0)?-(x):(x))
// mylittlepony
using namespace std;
int main() {
// freopen("treasures.in","r",stdin);
int T;
scanf(" %d",&T);
for(int t =0; t < T; t++) {
int N,M,Tt,x,y;
scanf(" %d %d %d %d %d",&N,&M,&Tt,&x,&y);
x--, y--;
vector< vector<long long> > C(N, vector<long long>(M));
for(int i =0; i < N*M; i++) scanf(" %lld",&C[i/M][i%M]);
long long mod =1000000007;
vector< vector< vector<long long> > > A(Tt+1,vector< vector<long long> >(N+M,vector<long long>(N+M,0)));
vector< vector< vector<long long> > > S(Tt+1,vector< vector<long long> >(N+M+1,vector<long long>(N+M+1,0)));
for(int i =0; i < N; i++) for(int j =0; j < M; j++) A[1][i+j][i-j+M] =C[i][j];
for(int ta =2; ta <= Tt; ta++) {
for(int i =0; i < N+M; i++) for(int j =0; j < N+M; j++) {
S[ta-1][i+1][j+1] =S[ta-1][i][j+1]+S[ta-1][i+1][j]-S[ta-1][i][j]+A[ta-1][i][j];
S[ta-1][i+1][j+1] %=mod;
if(S[ta-1][i+1][j+1] < 0) S[ta-1][i+1][j+1] +=mod;}
for(int i =0; i < N; i++) for(int j =0; j < M; j++) {
int xa =max(0,i+j-(ta-1)), xb =min(N+M-1,i+j+(ta-1));
int ya =max(0,i-j-(ta-1)+M), yb =min(N+M-1,i-j+(ta-1)+M);
long long Sn =(S[ta-1][xb+1][yb+1]+S[ta-1][xa][ya]-S[ta-1][xa][yb+1]-S[ta-1][xb+1][ya])%mod;
if(Sn < 0) Sn +=mod;
A[ta][i+j][i-j+M] =Sn;}}
printf("Case %d: %lld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