A two-player normal-form game between players A and B is completely described by:
Both players choose their actions simultaneously — say player A plays ai and player B plays bj. The payoffs are then read from the matrices: player A receives PA[i,j] and player B receives PB[i,j]. Each player wants to maximize their own payoff.
Given a fixed action bj of player B, a best response of player A is any action ai that maximizes A's payoff, that is, any ai with PA[i,j]=maxi′PA[i′,j]. Symmetrically, given a fixed action ai of player A, a best response of player B is any action bj with PB[i,j]=maxj′PB[i,j′].
A pair of actions (ai,bj) is a pure-strategy Nash equilibrium if ai is a best response to bj and, at the same time, bj is a best response to ai.
Given the two payoff matrices PA and PB, find and list all pure-strategy Nash equilibria of the game.
The input contains multiple test cases.
Each test case begins with a line containing two integers m and n (1≤m,n≤20). The next m lines give the rows of payoff matrix PA, and the following m lines give the rows of payoff matrix PB; each row lists n integers. Every payoff value is an integer in the range −100 to 100, inclusive.
The input ends with a line 0 0, which must not be processed.
For each test case, let N be the number of pure-strategy Nash equilibria of the game. Output:
List the equilibria in lexicographic order: (ai1,bj1) comes before (ai2,bj2) if i1<i2, or if i1=i2 and j1<j2.
Consider a game in which players A and B each have two actions, with the payoff matrices shown below:

If player A plays a1, then player B maximizes their payoff by playing b1, since PB[1,1]=1>0=PB[1,2]. Likewise, if player B plays b1, then player A maximizes their payoff by playing a1, since PA[1,1]=1>0=PA[2,1]. So a1 is a best response to b1 and vice versa, which makes (a1,b1) a pure-strategy Nash equilibrium.
By contrast, (a2,b2) is not a Nash equilibrium: if player A plays a2, then B's best response is b1, because PB[2,1]=5>3=PB[2,2].