Under construction

Still being built. Things may change

Red and Blue

Time limit2sMemory limit32 MB

Summary
Given merge, loss, and red-count range observations on bags of marbles, decide if a red/blue coloring fits all entries and print one.
Level

Hard8 of 10

Topics
Union-find, Prefix sum, Shortest path
Solved
No attempts yet

Problem

Pay attention to the memory limit.

When he was young, Jeyeon had NN marbles numbered from 11 to NN. Each marble was either red or blue. Jeyeon stored the marbles by putting each one into one of NN distinct bags.

Jeyeon valued his marbles, so he wrote down every action he took with them in a diary, in order. Each diary entry is one of the following three types.

  • 1 i j : Merge the bag containing marble ii with the bag containing marble jj. (1≤i,j≤N1\leq i, j \leq N)
  • 2 i : Marble ii was lost while he was playing with it. (1≤i≤N1\leq i \leq N) Sadly, the lost marble was never found again.
  • 3 i l h : Observe the bag containing marble ii. That bag contained at least ll and at most hh red marbles. (1≤i≤N,0≤l≤h≤N1 \leq i \leq N, 0 \leq l \leq h \leq N)

Ten years later, Jeyeon found a diary with MM entries. He now wants to reconstruct the color of each marble from the diary. Help him do it.

Marbles were always kept inside bags, and the diary is assumed to record every movement or change of a marble.

Input

The first line contains two integers NN and MM (2≤N≤2 000,,1≤M≤4 0002 \leq N \leq 2\ 000,\\, 1 \leq M \leq 4\ 000).

The next MM lines contain the diary entries in the format described above. Only marbles that have not been lost appear in the entries. In a type 1 entry, marble ii and marble jj are guaranteed to be in different bags.

Output

If there is a color assignment for the NN marbles that satisfies all MM entries, print YES. Otherwise, print NO.

If such an assignment exists, print on the next line a string of length NN. The ii-th character is R if marble ii is red and B if it is blue. If there are several answers, you may print any of them.

Examples2

  1. Example 1

    Input
    5 9
    1 2 4
    1 1 5
    3 4 1 2
    3 5 0 1
    1 4 1
    3 4 2 5
    2 1
    3 4 0 1
    3 3 1 1
    
    Expected output
    YES
    RBRRB
    
  2. Example 2

    Input
    3 4
    1 1 2
    3 2 1 2
    1 2 3
    3 3 0 0
    
    Expected output
    NO