QOJ.ac

QOJ

Süre Sınırı: 1 s Bellek Sınırı: 256 MB Toplam puan: 100 Hack'lenebilir ✓

#18953. Light Strip

İstatistikler

May 24 is Little X's birthday. To celebrate his birthday, his friends prepared a birthday party for him. There is a very important prop at this party—the light strip. The light strip needs to hold $n$ lights (no position may be left empty), and each light can be one of three colors: red, green, or blue. In order to reduce the cost as much as possible, the friends prepared exactly $r$, $g$, and $b$ red, green, and blue lights respectively, and exactly $n$ lights in total.

However, Little X has his own preferences for the light strip. Specifically, his preferences consist of $m$ pairs $(l_1, r_1), \dots, (l_m, r_m)$. He hopes that for every $i$, among the lights from $l_i$ to $r_i$ there are at most two different colors. It is guaranteed that for any $1 \le i \le m$, $1 \le l_i \le r_i \le n$, and for any $1 \le i < j \le m$, either $r_i < l_j$ or $r_j < l_i$ (that is, the intervals $[l_i, r_i]$ and $[l_j, r_j]$ are disjoint).

Now Little X's friends need to construct an arrangement satisfying Little X's preferences. But there are really too many lights, so it is hard for them to come up with an arrangement quickly. They turn to you, who can program, for help. Please help them construct a light strip arrangement satisfying Little X's preferences, or tell them that no such arrangement exists.

Input

This problem contains multiple test cases.

The first line contains an integer $T$ $(1 \le T \le 10^5)$, indicating the number of test cases.

For each test case:

The first line contains two positive integers $n, m$ and three nonnegative integers $r, g, b$ $(1 \le m \le n \le 10^5, 0 \le r, g, b \le n, r+g+b=n)$, denoting the length of the light strip, the number of $(l, r)$ pairs in Little X's preferences, and the numbers of red, green, and blue lights, respectively.

The next $m$ lines, the $i$-th line contains two positive integers $l_i, r_i$ $(1 \le l_i \le r_i \le n)$. It is guaranteed that for any $1 \le i < j \le m$, either $r_i < l_j$ or $r_j < l_i$.

It is guaranteed that the sum of $n$ over all test cases does not exceed $2 \times 10^5$.

Output

For each test case, if a valid arrangement exists, output a line containing a string of length $n$ consisting only of R, G, B, where R, G, B represent red, green, and blue lights respectively. You need to ensure that the counts of R, G, and B in the string are exactly the corresponding $r, g, b$ of that test case. If no valid arrangement exists, output $-1$.

Examples

Input 1

3
3 2 1 1 1
1 2
3 3
4 1 1 1 2
1 3
6 1 2 2 2
1 5

Output 1

BGR
BBGR
-1

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.