Under construction

Still being built. Things may change

LED-led Paths

Time limit3sMemory limit512 MB

Summary
Color each directed edge of an acyclic graph red, green, or blue so that no single-color directed path has more than 42 edges.
Level

Hard9 of 10

Topics
Graph, Topological sort, Dynamic programming
Solved
No attempts yet

Problem

A large city has nn junctions and mm one-way streets connecting them. The city has no directed cycles, so one cannot walk along the streets forever.

The tourism department will light each street with one of three colors: red (R), green (G), or blue (B). The official tourist maps show the chosen colors. Every continuous path whose streets all share one color is suggested for walking and sightseeing. These paths are called LED-led paths.

The health department warns that a very long single-color path may tempt tourists to overestimate their strength, walk too long, and grow tired of the city.

Propose a three-color illumination plan in which no single-color LED-led path consists of more than 42 streets.

Input

The first line contains two integers nn and mm, the number of junctions and streets (2≤n≤50 0002 \le n \le 50\,000, 1≤m≤200 0001 \le m \le 200\,000).

Each of the following mm lines contains two integers uiu_i and viv_i, denoting a one-way street from junction uiu_i to junction viv_i (1≤ui,vi≤n1 \le u_i, v_i \le n; ui≠viu_i \ne v_i).

The given city is guaranteed to be acyclic. Each pair of junctions is connected by at most one street.

Output

For each street, in the order of input, print its color on a separate line: a single letter R, G, or B.

Hint

In this example, every single-color LED-led path is at most one street long, so none exceeds the 42-street limit set by the health department.

Examples1

  1. Example 1

    Input
    5 6
    5 3
    3 1
    1 2
    2 4
    5 2
    3 4
    
    Expected output
    B
    R
    G
    R
    B
    G