N, K = map(int, input().split()) AC = [] for _ in range(K): a, c = input().split() AC.append((int(a), c)) AC.sort() ans = [] dic = {"R": 0, "G": 1, "B": 2} color = ["R", "G", "B"] X = [0, 0, 0] used = 0 for a, c in AC: unused = a - used i = dic[c] xnow = X[i] xmax = max(X) xdif = xmax - xnow if unused < xdif: print(-1) exit() else: X[i] += xdif ans += [c] * xdif unused -= xdif used += xdif Y = X[0:] Y.sort() x2nd = Y[1] xdif2 = xmax - x2nd xadd = - ((- unused + xdif2) // 2) X[i] += xadd ans += [c] * xadd used += xadd ans += ["R"] * (N - used) print("".join(ans))