Two players play a one-shot game. The row player has m actions, the column player has n actions. If the row player picks action i and the column player picks action j, the row player receives payoff a_ij and the column player receives payoff b_ij.
A profile (i, j) is a pure strategy Nash equilibrium if neither player can strictly increase their own payoff by unilaterally switching to a different action: no k satisfies a_kj > a_ij, and no l satisfies b_il > b_ij.
Find all pure strategy Nash equilibria of the game.
The first line contains m and n. The next m lines contain n integers each — the matrix A = (a_ij). The following m lines contain n integers each — the matrix B = (b_ij).
On the first line, output the number of pure strategy Nash equilibria. Then output one equilibrium per line as two integers i and j (1-indexed), sorted lexicographically. If there are none, output 0.
1 <= m, n <= 50
|a_ij|, |b_ij| <= 10^6
This is a standard problem: a submission scores full points if it produces the correct output for every test case, and zero otherwise.
2 2 3 0 5 1 3 5 0 1
1 2 2
2 2 1 -1 -1 1 -1 1 1 -1
0
3 3 4 0 0 0 2 0 0 0 1 4 0 0 0 2 0 0 0 1
3 1 1 2 2 3 3