Little Mirko got a new mobile phone for his birthday! As all kids nowadays, he quickly downloaded all of the popular mobile games, including Jetpack Joyride.
In the game, the protagonist Barry is running across a field consisting of
When Mirko presses the phone screen, Barry turns on his super-duper special jetpack and starts his ascent at the speed of one square per second (still moving to the right, now moving diagonally up at an angle of
Mirko just started playing the game recently and he's still not good at it. He saw on YouTube that someone managed to complete the game by crossing all
Input Specification
The first line of input contains the integer
Each of the following .
and X
, the layout of the field in the game. The characters X
denote obstacles, and .
walkable fields.
Output Specification
The first line of output must contain the integer
In the following
A move is determined by two integers
A series of moves must be sorted in chronological order. In other words, it must hold
Also, no move should begin after the end of the game,
The input data will be such that a solution will surely exist.
Sample Input 1
11
.....XX...X
....XX...XX
...XX...XX.
...........
....XXX....
...........
.....X.....
....XX...X.
...XX...XX.
...X...XX..
Sample Output 1
2
1 4
7 2
Explanation for Sample Output 1
The path Mirko has to take is denoted with *
:
.....XX...X
....XX...XX
...XX...XX.
...........
....XXX....
.....*...*.
....*X*.*.*
...*XX.*.X.
..*XX...XX.
**.X...XX..
Sample Input 2
20
X..................X
.X................X.
..X..............X..
...X............X...
....X..........X....
.....X........X.....
......X......X......
.......X....X.......
........X..X........
.........XX.........
Sample Output 2
1
8 10
Comments