#include <bits/stdc++.h>
#pragma warning(disable : 4996)
using namespace std;
char dat[30];
int xdat[30];
int p;
int n, m;
vector<int> edge[500];
vector<int> redge[500];
char a[500];
char dab[500];
int check[500];
vector<int> ord;
int group[500];
int groupi;
int usable[500][2];
int usable2[500][2];
void back(int now) {
  check[now] = 1;
  for (auto e : edge[now]) {
    if (check[e]) continue;
    back(e);
  }
  ord.push_back(now);
}
void back2(int now) {
  check[now] = 1;
  group[now] = groupi;
  for (auto e : redge[now]) {
    if (check[e]) continue;
    back2(e);
  }
}
int isgood() {
  int i;
  fill(check, check + n * 2, 0);
  ord.clear();
  for (i = 0; i < n * 2; i++) {
    if (check[i]) continue;
    back(i);
  }
  fill(check, check + n * 2, 0);
  groupi = 0;
  for (i = ord.size() - 1; i >= 0; i--) {
    if (check[ord[i]]) continue;
    back2(ord[i]);
    groupi++;
  }
  for (i = 0; i < n; i++) {
    if (group[i * 2] == group[i * 2 + 1]) {
      return 0;
    }
  }
  return 1;
}
void xback(int now, char nowmin, int flag) {
  int i, j, k;
  int ch[2] = {
      0,
  };
  int xflag = 0;
  i = now;
  if (now == n) {
    printf("%s", dab);
    exit(0);
  }
  if (flag == 0) {
    j = nowmin;
    int u = xdat[j];
    int suc = 0;
    if (u == 0) {
      edge[i * 2 + 1].push_back(i * 2);
      redge[i * 2].push_back(i * 2 + 1);
      if (!isgood()) {
        edge[i * 2 + 1].pop_back();
        redge[i * 2].pop_back();
      } else
        suc = 1;
    } else {
      redge[i * 2 + 1].push_back(i * 2);
      edge[i * 2].push_back(i * 2 + 1);
      if (!isgood()) {
        redge[i * 2 + 1].pop_back();
        edge[i * 2].pop_back();
      } else
        suc = 1;
    }
    if (suc) {
      xflag = 1;
      dab[i] = j + 'a';
      xback(now + 1, a[now + 1] - 'a', 0);
      if (u == 0) {
        edge[i * 2 + 1].pop_back();
        redge[i * 2].pop_back();
      } else {
        redge[i * 2 + 1].pop_back();
        edge[i * 2].pop_back();
      }
    }
    nowmin++;
  }
  for (j = nowmin; j < p; j++) {
    int u = xdat[j];
    if (ch[u] == 0) {
      ch[u] = 1;
      int suc = 0;
      if (u == 0) {
        edge[i * 2 + 1].push_back(i * 2);
        redge[i * 2].push_back(i * 2 + 1);
        if (!isgood()) {
          edge[i * 2 + 1].pop_back();
          redge[i * 2].pop_back();
        } else
          suc = 1;
      } else {
        redge[i * 2 + 1].push_back(i * 2);
        edge[i * 2].push_back(i * 2 + 1);
        if (!isgood()) {
          redge[i * 2 + 1].pop_back();
          edge[i * 2].pop_back();
        } else
          suc = 1;
      }
      if (!suc) continue;
      xflag = 1;
      dab[i] = j + 'a';
      xback(now + 1, 0, 1);
      if (u == 0) {
        edge[i * 2 + 1].pop_back();
        redge[i * 2].pop_back();
      } else {
        redge[i * 2 + 1].pop_back();
        edge[i * 2].pop_back();
      }
      break;
    }
  }
  if (xflag == 0) return;
}
int main() {
  int i, j, k;
  scanf("%s", dat);
  p = strlen(dat);
  for (i = 0; i < p; i++) xdat[i] = dat[i] == 'V' ? 1 : 0;
  scanf("%d%d", &n, &m);
  for (i = 0; i < m; i++) {
    int x, y;
    char z[3], w[3];
    scanf("%d%s%d%s", &x, z, &y, w);
    x--, y--;
    int xx, yy;
    xx = z[0] == 'V' ? 1 : 0;
    yy = w[0] == 'V' ? 1 : 0;
    edge[x * 2 + xx].push_back(y * 2 + yy);
    redge[y * 2 + yy].push_back(x * 2 + xx);
    edge[y * 2 + !yy].push_back(x * 2 + !xx);
    redge[x * 2 + !xx].push_back(y * 2 + !yy);
  }
  scanf("%s", a);
  for (i = 0; i < n; i++) {
    for (j = a[i] - 'a'; j < p; j++) {
      usable[i][xdat[j]] = 1;
    }
  }
  xback(0, a[0] - 'a', 0);
  printf("-1");
  return 0;
}
