A lecturer of the Ural State University has bought an amusing toy
in Tokyo: a small airplane and a set of plastic plates. The plates can be
put together to form a path for the plane the same way as a puzzle
can be assembled from pieces. There are many ways to put together the
plates, but if one makes it the right way, a map of Japan is
assembled, and the plane will go along a closed path visiting all
major Japan's sights. Try to guess what the lecturer's wife said when she
saw the toy—“Thank you!” or “Was it necessary to spend so much
money on such rubbish?” No, she said: “What a pity that you haven't
bought several sets! We could assemble a much longer path!”
Imagine that you have many plates with path segments. What is the
longest closed path that you can assemble?
The plates can be assumed to be squares of equal size, and the path
always connects the centers of two sides of a square. It means that
there are two kinds of plates: with straight lines and with turns.
The only line of the input contains two integers: the number of plates with
straight segments S and the number of plates with turns T
(0 ≤ S, T ≤ 1000,
S + T > 0).
In the first line output the maximal number of plates N that can be
used to assemble a path for the plane. In the second line output the
path in the following format: a line of length N consisting of
letters F, L, and R. Here F means that the
corresponding segment of the path is straight, L denotes a left
turn, and R denotes a right turn. The total number of letters F
must not exceed S, and the total number of letters L and R
must not exceed T. The path must be closed (the last square must
join the first square) and the squares can't overlap. If it is impossible to
assemble a closed path from the available plates, then output
“Atawazu” (“Impossible”, Jap.).
Problem Author: Stanislav Vasilyev (prepared by Vladimir Yakovlev)
Problem Source: The 11th Urals Collegiate Programing Championship, Ekaterinburg, April 21, 2007