Once upon a time, there was a country with cities and bidirectional roads connecting them. Technical development led to faster and larger road vehicles which presented a problem — the roads were becoming too narrow for two vehicles travelling in opposite direction. A decision to solve this problem involved turning all the roads into single-lane, one-way (unidirectional) roads.
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 . Its -th character should be
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 and the number of roads . The following lines describe the roads with pairs of numbers and , which indicate that there is a road between cities and . There can be more than one road between the same pair of cities and a road can even connect the city with itself.
The next line contains the number of pairs of cities that have to be reachable. The next lines contain pairs of cities and , meaning that there has to be a way to start in city and reach .
Constraints
Subtask 1 (30%)
Subtask 2 (30%)
Subtask 3 (40%)
- no additional constraints
Output
Output a string of length as described in the description of the task.
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