help in RRMAXTRIX

[http://www.codechef.com/problems/RRMATRIX][1]
I read the editorial.
Every element is in form of 
   Ai, j = i * M + j + 1
   Bi, j = j * N + i + 1

   equating the two, we get

        i * M + j + 1 = j * N + i + 1
    ⇒ i * (M-1) = j * (N-1)
    ⇒ i / j = (N-1) / (M-1) = p / q
    up to now every thing is clear,but i cant understand the next steps,and i thing(i,j) gives the postions of similar elements in both matrices,but what is (l*p,l*q) cant understand any one please help. 

//