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

Open Ural FU Personal Contest 2012

About     Problems     Submit solution     Judge status     Standings
Contest is over

G. Meander

Time limit: 1.0 second
Memory limit: 64 MB
Problem illustration
Robot Grand Master E2E4 lost disgracefully in 128th-finals of the Galaxy Meander Championships. He practically won the party, but then made an incredible mistake: he simply didn’t notice the winning move! Inspired by this mistake his counterpart used the opportunity and won. It seems that some piece of E2E4’s artificial brain started hiccupping. Will you manage to help the robot quickly so that he never loses meander games in this shameful way?
To play meander, 24 square tiles are used. They are laid out on the square board of 25 squares so that one square is always unoccupied. If one looks at the board from above, he can see that 12 tiles have pattern of the first type, and the other 12 tiles have pattern of the second type (see the picture on the right). Example initial position is shown in the picture.
Problem illustration
Players make moves in turns. In one move a player can simultaneously move one, two, three or four tiles along one of the sides of the playing board. Tiles are moved on the surface of the board, they can’t be turned. The game goes on until one of the players wins by making a pattern in which at least three tiles form a solid line connecting two edges of the board (either opposite or adjacent). Such a pattern is shown in the picture on the left (the line connects the left and the bottom edges of the board).
Write a program which defines if the specified pattern is winning, and if not, whether there exists a winning move.

Input

Input data represents five lines each containing five symbols. Symbol “*” marks an empty square. Symbol “/” marks the pattern of the first type, and symbol “\” marks the pattern of the second type. It is guaranteed that the input data contains exactly one symbol “*”, 12 symbols “/”, and 12 symbols “\”.

Output

Output “WIN” if the pattern is already winning. If it is not winning, but there is a move that makes it so, print this move. The move is described with two symbols: the first one specifies the direction of the move (“L” is left, “R” is right, “D” is down, “U” is up), and the second one specifies the amount of the tiles moved (from 1 to 4). For example, “U2” means “Move two tiles up”. If there are several moves, making the specified pattern winning, output any of them. If the pattern is not victorious and it cannot be made victorious in one move, output “FAIL”.

Samples

inputoutput
*/\//
\/\\\
\////
/\\\\
\//\/
WIN
\/\/\
\/\//
//\/*
\\\/\
\//\/
D2
Problem Author: Andrey Demidov
Problem Source: Open Ural FU Personal Contest 2012
To submit the solution for this problem go to the Problem set: 1947. Meander