#include <bits/stdc++.h>
using namespace std;
//#define endl '\n'

vector <vector <int> > ans;
void border(int offset, int n, int m, int c) {
	for (int i = 0; i < n; i++) ans[offset + i][offset] = ans[offset + i][m + offset - 1] = c;
	for (int j = 0; j < m; j++) ans[offset][offset + j] = ans[n + offset - 1][offset + j] = c;
}

void printAns() {
	for (int i = 0; i < (int)ans.size(); i++) {
		for (int j = 0; j < (int)ans[i].size(); j++) cout << ans[i][j] << ' ';
		cout << endl;
	}
}

void solve() {
	int n, m, k;
	cin >> n >> m >> k;
	int n2 = n / 2, m2 = m / 2;
	
	if (n % 2 == 1 || m % 2 == 1 || k > n2 * m2 || k < max(n2, m2) || k == n2 * m2 - 1) {
		cout << "NO\n";
		return;
	}
	
	ans.resize(n);
	for (int i = 0; i < n; i++) ans[i].resize(m, 0);
	
	int offset = 0;
	while (n > 2 && m > 2) {
		if (k == n2 * m2) break;
		
		if ((n2 - 1) * (m2 - 1) == k) {
			if (min(n, m) == 4 || max(n, m) == 6) {
				cout << "NO\n";
				ans.clear();
				return;
			}
			
			if (n > m) border(offset, n - 2, m, k--);
			else border(offset, n, m - 2, k--);
			border(offset + 1, 4, 4, k--);
			break;
		}
		
		if ((n2 - 1) * (m2 - 1) + 1 < k) {
			int rows = 4, cols = 4, cnt = n2 * m2 - 2;
			while (cnt > k) {
				if (rows < n) rows += 2;
				else cols += 2;
				cnt--;
			}
			border(offset, rows, cols, k--);
			break;
			
		} else border(offset, n, m, k--);
		offset++; n2--; m2--; n -= 2; m -= 2;
	}
	
	for (int i = 0; i < (int)ans.size(); i++) {
		for (int j = 0; j < (int)ans[i].size(); j++) {
			if (ans[i][j] != 0) continue;
			ans[i][j] = ans[i + 1][j] = ans[i][j + 1] = ans[i + 1][j + 1] = k--;
		}
	}
	if (k > 0) {
		cout << "NO\n";
		ans.clear();
		return;
	}
	
	cout << "YES\n";
	printAns();
	ans.clear();
}

int main () {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	
	int t; cin >> t; while (t--) solve();
	return 0;
}
