#include "gen.h"

/**
 * Author: Niyaz Nigmatullin
 */

using namespace std;

int main(int argc, char **argv) {
	registerValidation(argc, argv);
	int tests = inf.readInt(1, MAX_TESTS, "t");
	inf.readEoln();
	int total_cells = 0;
	for (int test = 0; test < tests; test++) {
		setTestCase(test + 1);
		int n = inf.readInt(2, MAX_SIDE, "n");
		inf.readEoln();
		total_cells += n * n;
		ensuref(total_cells <= MAX_TOTAL_CELLS, "Total number of cells exceed %d", MAX_TOTAL_CELLS);
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				if (j > 0) inf.readSpace();
				inf.readInt(0, MAX_COLORS - 1, "c");
			}
			inf.readEoln();
		}
	}
	inf.readEof();
}
