#include <bits/stdc++.h>
using namespace std;
const int Q = 1005;
int a[Q][2][2], y[2][2], b[2][2], r[2][2];
bitset<Q << 1> s[Q << 1];
char op[1 << 10], nw[10];
int c[2][2];
void Mul(int a[][2], int b[][2]) {
  for (int i = 0; i < 2; i++)
    for (int j = 0; j < 2; j++) {
      c[i][j] = 0;
      for (int k = 0; k < 2; k++) c[i][j] ^= (a[i][k] & b[k][j]);
    }
  for (int i = 0; i < 2; i++)
    for (int j = 0; j < 2; j++) a[i][j] = c[i][j];
}
int xx[Q << 1];
void Gauss(int n, int m) {
  int x = 1, p = 1;
  while (x <= m) {
    if (p > n) {
      for (int i = x; i <= m; i++)
        if (s[i][n + 1]) {
          puts("NO");
          exit(0);
        }
      break;
    }
    if (!s[x][p]) {
      for (int i = x + 1; i <= m; i++)
        if (s[i][p]) {
          swap(s[x], s[i]);
          break;
        }
    }
    if (!s[x][p]) {
      ++p;
      continue;
    }
    for (int i = x + 1; i <= m; i++)
      if (s[i][p]) s[i] ^= s[x];
    ++x, ++p;
  }
  for (--x; x; --x) {
    int t = 1;
    while (!s[x][t]) ++t;
    xx[t] = s[x][n + 1];
    for (int i = t + 1; i <= n; i++)
      if (s[x][i]) xx[t] ^= xx[i];
  }
}
int main() {
  y[0][1] = y[1][0] = 1;
  b[0][0] = b[1][0] = b[1][1] = 1;
  r[0][0] = r[0][1] = r[1][1] = 1;
  int n, qaq, maxn = 0;
  scanf("%d%d", &n, &qaq);
  for (int i = 1; i <= n; i++)
    for (int j = 0; j < 2; j++) a[i][j][j] = 1;
  while (qaq--) {
    scanf("%s", op);
    if (op[0] == 'm') {
      int num, x;
      scanf("%d", &num);
      while (num--) {
        scanf("%d", &x);
        s[maxn + 1][x] = a[x][0][0], s[maxn + 1][x + n] = a[x][1][0];
        s[maxn + 2][x] = a[x][0][1], s[maxn + 2][x + n] = a[x][1][1];
      }
      scanf("%s", nw);
      if (nw[0] == 'B' || nw[0] == 'Y') s[maxn + 1][n << 1 | 1] = 1;
      if (nw[0] == 'R' || nw[0] == 'Y') s[maxn + 2][n << 1 | 1] = 1;
      maxn += 2;
      continue;
    }
    if (op[0] > op[1]) swap(op[0], op[1]);
    if (op[0] == 'B' && op[1] == 'R') {
      int num, x;
      scanf("%d", &num);
      while (num--) scanf("%d", &x), Mul(a[x], y);
    }
    if (op[0] == 'R' && op[1] == 'Y') {
      int num, x;
      scanf("%d", &num);
      while (num--) scanf("%d", &x), Mul(a[x], b);
    }
    if (op[0] == 'B' && op[1] == 'Y') {
      int num, x;
      scanf("%d", &num);
      while (num--) scanf("%d", &x), Mul(a[x], r);
    }
  }
  Gauss(n << 1, maxn);
  puts("YES");
  for (int i = 1; i <= n; i++)
    putchar(xx[i] ? (xx[i + n] ? 'Y' : 'B') : (xx[i + n] ? 'R' : '.'));
  return 0;
}
