> File Name: ecfinal_L.cpp
> Author: jiangyuzhu
> Mail: 834138558@qq.com
> Created Time: 2016/12/4 18:27:36
************************************************************************/
#include<iostream>
#include<cstdio>
#include<cstring>
#include<queue>
#include<vector>
#include<set>
#include<map>
#include<cmath>
#include<algorithm>
using namespace std;
typedef long long ll;
const int maxn = 1e3 + 5;
char s[10 + 5];
int mat[maxn][maxn];
int mx = 1e5 + 5;
int main (void)
{
int T;scanf("%d", &T);
for(int tt = 1; tt <= T; ++tt){
int r, c;
scanf("%d%d", &r, &c);
int ansr, ansc, ansr1, ansc1;
ansr = ansc = -1;
int cnt = 0;
for(int i = 1; i <= r; ++i){
for(int j = 1; j <= c; ++j){
scanf("%s", s);
if(s[0] == '?'){
mat[i][j] = 0;
}else{
mat[i][j] = (int)atoi(s);
if(ansr == -1) ansr = i;
else ansr1 = i;
if(ansc == -1) ansc = j;
else ansc1 = j;
cnt++;
}
}
}
int ansx, ansy;
int dx, dy;
int x, y;
bool flag = false;
if(!cnt) flag = true;
else if(cnt == 1){
for(x = 1; x <= mx; ++x){
if(mat[ansr][ansc] < x) break;
if(mat[ansr][ansc] % x != 0) continue;
dx = x - ansr, dy = mat[ansr][ansc] / x - ansc;
if(dx >= 0 && dy >= 0){
flag = true;
break;
}
dx = mat[ansr][ansc] / x - ansr, dy = x - ansc;
if(dx >= 0 && dy >= 0){
flag = true;
break;
}
}
}else{
int a1 = mat[ansr][ansc], a2 = mat[ansr1][ansc1];
for(x = 1; x <= mx; ++x){
if(a1 < x) break;
if(a1 % x != 0) continue;
y = a1 / x;
if(x < ansr || y < ansc) continue;
ll tmp = x * 1ll * (ansc1 - ansc) + y * 1ll * (ansr1 - ansr) + (ansc1 - ansc) * 1ll * (ansr1 - ansr);
if(tmp == (ll)(a2 - a1)) break;
swap(x, y);
tmp = x * 1ll * (ansc1 - ansc) + y * 1ll * (ansr1 - ansr) + (ansc1 - ansc) * 1ll * (ansr1 - ansr);
if(tmp == (ll)(a2 - a1)) break;
swap(x, y);
}
if(x * y == a1){
flag = true;
for(int i = 1; i <= r; ++i){
for(int j = 1; j <= c; ++j){
if(!mat[i][j]) continue;
if((ll)mat[i][j] != (x - ansr + i) * 1ll * (y - ansc + j)){
flag = false;
break;
}
}
}
}
}
if(flag) printf("Case #%d: Yes\n", tt);
else printf("Case #%d: No\n", tt);
}
return 0;
}