#include <bits/stdc++.h>
using namespace std;
const int N = 2005;
int n, K, ans[N];
struct mat {
  int x[2][2];
  void reset() { x[0][0] = x[1][1] = 1, x[0][1] = x[1][0] = 0; }
  mat operator*(const mat& b) const {
    mat c;
    memset(c.x, 0, sizeof(c.x));
    for (int i = (0); i <= (1); ++i)
      for (int j = (0); j <= (1); ++j)
        for (int k = (0); k <= (1); ++k) c.x[i][j] ^= x[i][k] & b.x[k][j];
    return c;
  }
} mm[N];
struct gauss {
  int n;
  bitset<N> f[N];
  int xid[N];
  void sol(int m) {
    int lst = 0;
    for (int i = (1); i <= (m); ++i) {
      int pos = -1;
      for (int j = (lst + 1); j <= (n); ++j)
        if (f[j][i]) {
          pos = j;
          break;
        }
      if (pos == -1) {
        continue;
      }
      ++lst, xid[lst] = i;
      swap(f[pos], f[lst]);
      for (int j = (lst + 1); j <= (n); ++j)
        if (f[j][i]) {
          f[j] ^= f[lst];
        }
    }
    for (int i = (lst + 1); i <= (n); ++i) {
      if (f[i][m + 1]) puts("NO"), exit(0);
    }
    for (int i = (lst); i >= (1); --i) {
      for (int j = (xid[i] + 1); j <= (m); ++j) {
        if (f[i][j]) f[i][j] = 0, f[i][m + 1] = f[i][m + 1] ^ ans[j];
      }
      ans[xid[i]] = f[i][m + 1];
    }
  }
} ga;
int main() {
  scanf("%d%d", &n, &K);
  for (int i = (1); i <= (n); ++i) mm[i].reset();
  for (int i = (1); i <= (K); ++i) {
    string s;
    cin >> s;
    if (s == "mix") {
      int len;
      scanf("%d", &len);
      for (int i = (1); i <= (len); ++i) {
        int k1;
        scanf("%d", &k1);
        ga.f[ga.n + 1][k1 * 2 - 1] = mm[k1].x[0][0];
        ga.f[ga.n + 1][k1 * 2] = mm[k1].x[0][1];
        ga.f[ga.n + 2][k1 * 2 - 1] = mm[k1].x[1][0];
        ga.f[ga.n + 2][k1 * 2] = mm[k1].x[1][1];
      }
      cin >> s;
      ga.f[ga.n + 1][n * 2 + 1] = s == "B" || s == "Y";
      ga.f[ga.n + 2][n * 2 + 1] = s == "R" || s == "Y";
      ga.n += 2;
    } else {
      mat cur;
      if (s == "YB") {
        cur = (mat){{{1, 0}, {1, 1}}};
      } else if (s == "RB") {
        cur = (mat){{{0, 1}, {1, 0}}};
      } else {
        cur = (mat){{{1, 1}, {0, 1}}};
      }
      int len;
      scanf("%d", &len);
      for (int i = (1); i <= (len); ++i) {
        int k1;
        scanf("%d", &k1);
        mm[k1] = cur * mm[k1];
      }
    }
  }
  ga.sol(n * 2);
  puts("YES");
  for (int i = (1); i <= (n); ++i) {
    if (ans[i * 2 - 1] == 0 && ans[i * 2] == 0) putchar('.');
    if (ans[i * 2 - 1] == 1 && ans[i * 2] == 0) putchar('B');
    if (ans[i * 2 - 1] == 0 && ans[i * 2] == 1) putchar('R');
    if (ans[i * 2 - 1] == 1 && ans[i * 2] == 1) putchar('Y');
  }
  puts("");
  return 0;
}
