public static void main(String[] args) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder out = new StringBuilder();
		int n = Integer.parseInt(in.readLine().trim());
		for (int i = 0; i < n; i++) {
			int[] rc = readInts(in.readLine());
			c = rc[0];
			r = rc[1];
			f = new HashMap<Point, String>();
			for (int j = 0; j < r; j++) {
				String[] row = in.readLine().trim().split(" ");
				for (int k = 0; k < row.length; k++)
					if (row[k].startsWith("="))
						f.put(new Point(j, k), row[k]);
					else
						m[j][k] = Integer.parseInt(row[k]);
			}
			for (int j = 0; j < r; j++) {
				for (int k = 0; k < c; k++) {
					if (k != 0)
						out.append(" ");
					out.append(solve(j, k));
				}
				out.append("\n");
			}
		}
		System.out.print(out);
	}