static void check_ans(int[][] professor_preference,
			int[][] student_preference, Pair<Integer, Integer>[] match_result) {
	  
		assert match_result.length == professor_preference.length;
		
		boolean[] professor = new boolean[professor_preference.length], 
				student = new boolean[student_preference.length];
		
		for (Pair<Integer, Integer> p : match_result) {
			student[p.getFirst()] = true;
			professor[p.getSecond()] = true;
		}
		for (boolean p : professor) {
			assert p;
		}
		for (boolean s : student) {
			assert s;
		}

		for (int i = 0; i < match_result.length; ++i) {
			for (int j = i + 1; j < match_result.length; ++j) {
				int s0 = match_result[i].getFirst(), a0 = match_result[i].getSecond();
				int s1 = match_result[j].getFirst(), a1 = match_result[j].getSecond();
				int a0_in_s0_order = find(student_preference[s0], a0);
				int a1_in_s0_order = find(student_preference[s0], a1);
				int s0_in_a1_order = find(professor_preference[a1], s0);
				int s1_in_a1_order = find(professor_preference[a1], s1);
				assert a0_in_s0_order < a1_in_s0_order
						|| s1_in_a1_order < s0_in_a1_order;
	    }
	  }
	}