#include <bits/stdc++.h>
#define ios ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define file(s) if (fopen(s".in", "r")) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout)
#define all(a) a.begin() , a.end()
#define F first
#define S second
#define int ll 
using namespace std;
using ll = long long;
const ll N = 2e5+5  , inf = 2e9+7;
const ll INF = 1e18 ,   mod = 987654321;
vector<int> a[N];
int n , m , k;
void go(int kol){
	int cur = 0;
	for(int k1 = 1; k1 <= kol; k1++){
		cur++;
		for(int i = k1; i <= n-k1+1; i++){
			a[i][k1] = cur; 
			a[i][m-k1+1] = cur; 
		}
		for(int j = k1; j <= m-k1+1; j++){
			a[k1][j] = cur; 
			a[n-k1+1][j] = cur; 
		}
	}
	for(int i = kol+1; i+1 <= n-kol; i += 2){
		for(int j = kol+1; j+1<= m-kol; j += 2){
			a[i][j] = a[i][j+1] = a[i+1][j] = a[i+1][j+1] = ++cur;
		}
	}
	cout << "YES\n";
	for(int i = 1; i <= n; i++){
		for(int j = 1; j <= m; j++){
			cout << a[i][j] <<" ";
		}
		cout << "\n";
	}	
	return; 	
}
void solve(){
	cin >> n >> m >> k; 
	for(int i = 0; i <= n+1; i++){
		a[i].resize(m+9);
	}
	if(n % 2 || m % 2){
		cout << "NO\n";
		return;
	} else {
		int n1 = n , m1 = m , bar = n*m;
		for(int i = 0; i <= min(n/2,m/2); i++){
			if(i == 0){
				if(n*m/4 == k){
					go(i);
					return;
				}
			} else {
				bar -= n1;
				bar -= n1;
				bar -= m1;
				bar -= m1;
				bar += 4;
				n1-= 2;
				m1-= 2;
				if(bar/4+i == k){
					go(i);
					return;
				}
			}
		}
		cout << "NO\n";
		return;
	}
}	
/*
*/
signed main(){
	ios;
	int t;
	cin >> t;
	while(t--) solve();
}
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... |