#P4794. Alternating Current

    ID: 18038 Type: Default 1000ms 256MiB

Alternating Current

Alternating Current

This problem is translated from BalticOI 2018 Day2 "Alternating Current". You are given a circular track divided into \(N\) equal segments numbered from \(1\) to \(N\). There are \(M\) control points; each control point can color a contiguous portion of the track either red or blue. Specifically, the \(i\)th control point colors the segment from \(l_i\) to \(r_i\) (inclusive). Note that if \(l_i > r_i\), then the segment covers \([l_i, N]\) and \([1, r_i]\). It is guaranteed that every segment on the track can be colored (i.e. every segment is covered by at least one control point).

Your task is to assign a color (red or blue) to each control point so that every segment on the track is covered by at least one red portion and at least one blue portion.

inputFormat

The first line contains two integers \(N\) and \(M\). The next \(M\) lines each contain two integers \(l_i\) and \(r_i\), representing the starting and ending segments (inclusive) for the \(i\)th control point. If \(l_i > r_i\), then the interval covers \([l_i, N]\) and \([1, r_i]\) due to the circular nature of the track.

outputFormat

Output a string of length \(M\) consisting of characters 'R' and 'B'. The \(i\)th character indicates the color assigned to the \(i\)th control point. The output must satisfy that every segment on the circular track is covered by at least one 'R' (red) and at least one 'B' (blue).

sample

6 4
1 4
3 6
5 2
2 5
BBRR