Amidst his journey through the Borderlands, Arisu stumbles upon a diamonds game involving an
- A coin may only be removed from the grid if it is heads.
- When a coin is removed, the coins in the cells that share an edge with it are flipped (if they exist).
Unfortunately, diamonds is not one of Arisu's strong suits. Help him beat the game, or determine that it's impossible to do so!
Constraints
Subtask 1 [25%]
Subtask 2 [75%]
No additional constraints.
Input Specification
The first line contains
The next H
if the coin in cell T
if it is initially tails.
Output Specification
If it is impossible to beat the game, output
Otherwise, output
Sample Input 1
3 3
HTH
THT
HTH
Sample Output 1
2 2
1 1
1 3
3 1
3 3
1 2
2 1
2 3
3 2
Sample Input 2
1 3
HHT
Sample Output 2
-1
Comments