#include <bits/stdc++.h>
#define fir first
#define sec second
#define el '\n'
#define debug(x) cout << #x << ":: " << x << endl;
#define FINISH cout << "FINISH" << endl;
#define debugv(x) cout << #x << ":: ";\
for (auto i : x) \
cout << i << " "; \
cout << endl
using namespace std;
using ll = long long;
using PII = pair<int, int>;
const int inf = 0x3f3f3f3f;
const int N = 200020;
void solve()
{
int n,m;
cin>>n>>m;
cout<<"YES\n";
vector<vector<int>> a(n,vector<int>(m,0));
int cnt=0;
for(int i=0;i<n+m-1;i++){
for(int j=0;j<=i;j++){
int x=j,y=i-j;
if(x>=0&&x<n&&y>=0&&y<m){
cnt++;
a[x][y]=cnt;
}
}
}
for(auto x:a){
for(int y:x){
cout<<y<<" ";
}
cout<<"\n";
}
return;
}
int main()
{
ios:: sync_with_stdio("false");
cin.tie(nullptr);
cout.tie(nullptr);
int T= 1;
cin>>T;2 3
while (T--) {
solve();
}
return 0;
}