#include <bits/stdc++.h>
using namespace std;
int n, K;
int CtoI(int x) {
  if (x == 'R') return 1;
  if (x == 'Y') return 2;
  if (x == 'B') return 3;
  if (x == 'W') return 0;
}
int ItoC(int x) {
  if (x == 1) return 'R';
  if (x == 2) return 'Y';
  if (x == 3) return 'B';
  if (x == 0) return '.';
}
int ar[2005], mt[2005][2][2], cx[2005], cy[2005];
bitset<2005> a[2005];
int main() {
  scanf("%d%d", &n, &K);
  for (int i = (0), LIM = (n - 1); i <= LIM; i++) mt[i][0][0] = mt[i][1][1] = 1;
  for (int i = (0), LIM = (K - 1); i <= LIM; i++) {
    int m, x, cl;
    char ch[10], col[2];
    scanf("%s", ch);
    scanf("%d", &m);
    for (int j = (1), LIM = (m); j <= LIM; j++) scanf("%d", &ar[j]), ar[j]--;
    if (ch[0] == 'm') {
      scanf("%s", col);
      cl = CtoI(col[0]);
      for (int j = (1), LIM = (m); j <= LIM; j++) {
        if (mt[ar[j]][0][0]) a[i << 1][ar[j] << 1] = a[i << 1][ar[j] << 1] ^ 1;
        if (mt[ar[j]][0][1])
          a[i << 1 | 1][ar[j] << 1] = a[i << 1 | 1][ar[j] << 1] ^ 1;
        if (mt[ar[j]][1][0])
          a[i << 1][ar[j] << 1 | 1] = a[i << 1][ar[j] << 1 | 1] ^ 1;
        if (mt[ar[j]][1][1])
          a[i << 1 | 1][ar[j] << 1 | 1] = a[i << 1 | 1][ar[j] << 1 | 1] ^ 1;
      }
      a[i << 1][n << 1] = cl & 1;
      a[i << 1 | 1][n << 1] = cl & 2;
    } else {
      int b[2][2] = {};
      if (ch[0] == 'R' && ch[1] == 'Y') {
        b[1][0] = b[0][1] = 1;
      }
      if (ch[0] == 'R' && ch[1] == 'B') {
        b[0][0] = b[1][1] = b[0][1] = 1;
      }
      if (ch[0] == 'Y') {
        b[0][0] = b[1][1] = b[1][0] = 1;
      }
      for (int j = (1), LIM = (m); j <= LIM; j++) {
        static int c[2][2];
        memset(c, 0, sizeof c);
        int v = ar[j];
        for (int i = (0), LIM = (1); i <= LIM; i++)
          for (int j = (0), LIM = (1); j <= LIM; j++)
            for (int k = (0), LIM = (1); k <= LIM; k++)
              c[i][k] ^= mt[v][i][j] * b[j][k];
        for (int i = (0), LIM = (1); i <= LIM; i++)
          for (int j = (0), LIM = (1); j <= LIM; j++) mt[v][i][j] = c[i][j];
      }
    }
  }
  int r = 0;
  for (int i = (0), LIM = (2 * n - 1); i <= LIM; i++) {
    if (!a[r][i])
      for (int j = (r + 1), LIM = (2 * K - 1); j <= LIM; j++)
        if (a[j][i]) {
          swap(a[j], a[r]);
          break;
        }
    if (!a[r][i]) {
      cx[i] = 2005 - 1;
      continue;
    }
    cx[i] = r;
    for (int j = (r + 1), LIM = (2 * K - 1); j <= LIM; j++)
      if (a[j][i]) a[j] ^= a[r];
    r++;
  }
  for (int i = (2 * n - 1), LIM = (0); i >= LIM; i--)
    if (cx[i] != 2005 - 1) {
      for (int j = (i + 1), LIM = (2 * n - 1); j <= LIM; j++)
        if (a[cx[i]][j]) a[cx[i]][n << 1] = a[cx[i]][n << 1] ^ a[cx[j]][n << 1];
      if (!a[cx[i]][i] && a[cx[i]][n << 1]) {
        puts("NO");
        return 0;
      }
    }
  for (int i = (r), LIM = (2 * K - 1); i <= LIM; i++)
    if (a[i][n << 1]) {
      puts("NO");
      return 0;
    }
  puts("YES");
  for (int i = (0), LIM = (n - 1); i <= LIM; i++) {
    int cl = a[cx[i << 1]][n << 1] | (a[cx[i << 1 | 1]][n << 1] << 1);
    putchar(ItoC(cl));
  }
}
