Once upon a time, there was a country with
Making the roads one-way comes at a cost because some of those pairs of cities that were previously connected might no longer be reachable after the change. The government compiled a list of important pairs of cities for which it has to be possible to start in the first city and reach the second one. Your task is to determine in which direction to direct the traffic on every road. It is guaranteed that a solution exists.
For some roads, there is no choice about the direction of traffic if you want to obtain a solution. The traffic will flow from the first to the second city (right direction, indicated by letter R
) or from the second city towards the first (left direction, indicated by letter L
). However, for some roads there exists a solution with this road directed left, and another(possibly different) solution with the road directed right. You should indicate such roads with a letter B
for both directions.
Output a string of length
R
if all solutions require the -th road to be directed rightL
if all solutions require the -th road to be directed leftB
if a solution exists where the -th road is directed left, and a solution also exists where the -th road is directed right
Input
The first line contains the number of cities
The next line contains the number of pairs of cities
Constraints
Subtask 1 (30%)
Subtask 2 (30%)
Subtask 3 (40%)
- no additional constraints
Output
Output a string of length
Sample Input
5 6
1 2
1 2
4 3
2 3
1 3
5 1
2
4 5
1 3
Sample Output
BBRBBL
Explanation
Let's show that the fifth road 1 3
can be directed in either direction. Two possible orientations of roads with different directions of the fifth road are LLRLRL
and RLRRLL
.
Comments