ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules

1458. War Games

Time limit: 1.0 second
Memory limit: 64 MB

Background

One day the Minister of Defense of the Soviet Federation comrade Ivanov resolved to carry out large-scale war games for the military forces of the Federation. It was planned to perform a landing operation of unexampled complexity - to drop armored and rapid deployment forces directly onto the heads of imaginary terrorists. "That is how we crush the international terrorism", - the Minister explained.
General Rascal was appointed to be responsible for the war games. To begin with he plundered the allocated funds. Then he decided to refuse the expensive landing operation and come back to a traditional war games scheme.

Problem

A square parade-ground N*N cells in size is usually used for war games. A cell at the intersection of i-th horizontal and j-th vertical of the parade-ground has coordinates (i, j). A soldier is positioned is each cell. Any soldier of the Soviet Army may be in either opposite state - "Recline" or "Port". War games commander (here it is Mr. Rascal himself) stands on the platform near the parade-ground and sometimes shouts: "Cell (i, j)!" At this command, all the soldiers positioned on i-th horizontal or on j-th vertical (by the way, there are exactly 2*N-1 such soldiers) change their states to the opposite ones.
At the beginning of the war games each soldier will be in some initial state C[i, j], which will be determined by the Minister himself. And Mr. Rascal will have to turn all the soldiers to the same state (it does not matter in which of two) by means of some sequence of commands. It is written in the tactics manual, that this scheme allows to evaluate intellectual faculties and commander's skills of Soviet Army's supreme officers.
The general has some doubt in his intellectual faculties (as well as in his commander's skills) and wants to accept an assistance of sergeant Filcher. Tempted by the bottle of pure alcohol, the sergeant is ready to find a correct sequence of commands for any initial state of the soldiers. More over, for an extra bottle Mr. Filcher has agreed to find a correct sequence which consists of minimal possible number of commands.

Input

The first line contains the even integer number N (2 ≤ N ≤ 1000). Each of the next N lines contains N characters C[i, j]. Character "W" corresponds to the state "Recline", and character "B" corresponds to the state "Port".

Output

The first line should contain the number of commands in the desired sequence. Then for each command you should output the coordinates of the cell, which is mentioned in this command. Each pair of the coordinates should be printed in a separate line. The coordinates themselves should be separated by single space. If the problem has several solutions, you should output any of them.

Sample

inputoutput
4
WBWB
BWWW
WWBW
WBWB
2
2 3
3 1
Problem Author: Dmitry Kovalioff, Nikita Rybak, Ilya Grebnov. Thanks to Sergey Sofronov for the idea
Problem Source: Timus Top Coders: Second Challenge