public static void main(String[] args) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder out = new StringBuilder();
		int t = Integer.parseInt(in.readLine().trim());
		for(int tt = 0; tt<t; tt++){
			int size = Integer.parseInt(in.readLine().trim());
			m = new int[size][size];
			int inter = Integer.parseInt(in.readLine().trim());
			for (int i = 0; i < inter; i++) {
				int[] d = readInts(in.readLine());
				for (int r = d[0]-1; r < d[2]; r++) 
					for (int c = d[1]-1; c < d[3]; c++) 
						m[r][c] = 1;
			}
			long area = getMaxRectangleSum();
			out.append(area + "\n");
		}
		System.out.print(out);
	}