#include typedef struct { int key, id; } data; void merge_sort(int n, data x[]) { static data y[100001] = {}; if (n <= 1) return; merge_sort(n / 2, &(x[0])); merge_sort((n + 1) / 2, &(x[n/2])); int i, p, q; for (i = 0, p = 0, q = n / 2; i < n; i++) { if (p >= n / 2) y[i] = x[q++]; else if (q >= n) y[i] = x[p++]; else y[i] = (x[p].key < x[q].key)? x[p++]: x[q++]; } for (i = 0; i < n; i++) x[i] = y[i]; } int main() { int i, N, K, A[100001]; char c[100001]; scanf("%d %d", &N, &K); for (i = 1; i <= K; i++) scanf("%d %c ", &(A[i]), &(c[i])); // for (i = 1; i <= K; i++) printf("%d %c\n", A[i], c[i]); data d[100001]; for (i = 1; i <= K; i++) { d[i-1].key = A[i]; d[i-1].id = i; } merge_sort(K, d); int j, count[3] = {}; char ans[100001]; for (i = 0, j = 1; i < K; i++) { for (; j <= d[i].key; j++) { if (count[0] < count[1] || count[0] < count[2]) { count[0]++; ans[j-1] = 'R'; } else if (count[1] < count[0] || count[1] < count[2]) { count[1]++; ans[j-1] = 'G'; } else if (count[2] < count[0] || count[2] < count[1]) { count[2]++; ans[j-1] = 'B'; } else { if (c[d[i].id] == 'R') { count[0]++; ans[j-1] = 'R'; } else if (c[d[i].id] == 'G') { count[1]++; ans[j-1] = 'G'; } else { count[2]++; ans[j-1] = 'B'; } } } } ans[N] = 0; printf("%s\n", ans); fflush(stdout); return 0; }