The number we want to get is the position of the chosen square, which can be represented in binary as 00, 01, 10, or 11.
Let the "parity" of the first row determine the first character, and the parity of the first column determine the second character. By "parity", we mean if the number of heads is even, it represents 0, while if it is odd, it represents 1.
No matter how the Jailer has arranged the coins, we can flip over one coin to make the first row and first column give us the desired answer.
For instance, if the chosen square is upper right (01), and the jailer has set up the coins as
Which translates to 00
We would flip the lower left to get
the first row has two heads, so the first character is 0 and the first column has one head, so the second character is 1
If the coins placed by the jailer already point to the correct square, we would flip the lower right coin, since it doesn't affect the parity of either the first column or the first row.
For a fuller discussion of the larger problem with a full chessboard, see