import sys # sys.setrecursionlimit(200005) int1 = lambda x: int(x)-1 pDB = lambda *x: print(*x, end="\n", file=sys.stderr) p2D = lambda x: print(*x, sep="\n", end="\n\n", file=sys.stderr) def II(): return int(sys.stdin.readline()) def LI(): return list(map(int, sys.stdin.readline().split())) def LLI(rows_number): return [LI() for _ in range(rows_number)] def LI1(): return list(map(int1, sys.stdin.readline().split())) def LLI1(rows_number): return [LI1() for _ in range(rows_number)] def SI(): return sys.stdin.readline().rstrip() dij = [(0, 1), (-1, 0), (0, -1), (1, 0)] # dij = [(0, 1), (-1, 0), (0, -1), (1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)] inf = (1 << 63)-1 # inf = (1 << 31)-1 # md = 10**9+7 md = 998244353 s = "RGB" n, k = LI() color = [set() for _ in range(n)] nxt = [-1]*n ac = [] for _ in range(k): a, c = SI().split() a = int(a)-1 c = s.find(c) color[a].add(c) nxt[a] = c ac.append((a, c)) for i in range(n-1)[::-1]: color[i] |= color[i+1] if nxt[i] == -1: nxt[i] = nxt[i+1] # print(color) # print(nxt) aa = [-1]*n cnt = [0, 0, 0] for i in range(n): nc = nxt[i] if cnt[nc] != max(cnt): aa[i] = nc else: mnc, mn = 0, inf for c in color[i]: if cnt[c] < mn: mn, mnc = cnt[c], c if mn == cnt[nc]: aa[i] = nc else: aa[i] = mnc cnt[aa[i]] += 1 ac.sort(reverse=True) cnt = [0, 0, 0] for i, a in enumerate(aa): cnt[a] += 1 if ac and ac[-1][0] == i: _, c = ac.pop() if cnt[c] != max(cnt): print(-1) exit() print("".join(s[i] for i in aa))