#include <bits/stdc++.h>
using namespace std;
const int N = 200 + 10;
int rd() {
  int x = 0, w = 1;
  char ch = 0;
  while (ch < '0' || ch > '9') {
    if (ch == '-') w = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = (x << 3) + (x << 1) + (ch ^ 48);
    ch = getchar();
  }
  return x * w;
}
struct ed {
  int x, y;
};
vector<ed> ee[N][2];
char cc[30], ss[N], aa[N], an[N], ch0, ch1;
int n, m, l, lc, nb[N], st[N << 2][3], tp;
bool co[30], fk, zz[N];
bool putt(int x, int y) {
  if (y >= 26) return 0;
  if (~nb[x]) return nb[x] == co[y];
  st[++tp][0] = x, st[tp][1] = nb[x], st[tp][2] = aa[x];
  nb[x] = co[y], aa[x] = y + 'a';
  vector<ed>::iterator it;
  for (it = ee[x][nb[x]].begin(); it != ee[x][nb[x]].end(); ++it) {
    int y = (*it).x, z = (*it).y;
    if (!putt(y, ((z ^ fk) ? ch1 : ch0) - 'a')) return 0;
  }
  return 1;
}
bool dfs(int o) {
  if (o > lc) {
    bool ok = 1;
    for (int j = 1; j <= lc; ++j)
      if (aa[j] != an[j]) {
        ok = aa[j] <= an[j];
        break;
      }
    if (ok) memcpy(an, aa, sizeof(aa));
    return 1;
  }
  if (~nb[o]) return dfs(o + 1);
  int latp = tp;
  if (putt(o, ch0 - 'a')) {
    if (dfs(o + 1)) return 1;
    while (tp > latp)
      nb[st[tp][0]] = st[tp][1], aa[st[tp][0]] = st[tp][2], --tp;
    if (!zz[o]) return 0;
  }
  while (tp > latp) nb[st[tp][0]] = st[tp][1], aa[st[tp][0]] = st[tp][2], --tp;
  if (ch1 <= 'z' && putt(o, ch1 - 'a')) {
    if (dfs(o + 1)) return 1;
    while (tp > latp)
      nb[st[tp][0]] = st[tp][1], aa[st[tp][0]] = st[tp][2], --tp;
    return 0;
  }
  while (tp > latp) nb[st[tp][0]] = st[tp][1], aa[st[tp][0]] = st[tp][2], --tp;
  return 0;
}
int main() {
  scanf("%s", cc + 1), l = strlen(cc + 1);
  ch0 = ch1 = 127;
  for (int i = 1; i <= l; ++i) {
    if (cc[i] == 'C')
      co[i - 1] = 0, ch0 = min(ch0, (char)(i + 96));
    else
      co[i - 1] = 1, ch1 = min(ch1, (char)(i + 96));
  }
  if (ch0 > ch1) fk = 1, swap(ch0, ch1);
  n = rd(), m = rd();
  while (m--) {
    int x, z1, y, z2;
    x = rd(), scanf("%s", cc), z1 = cc[0] == 'V';
    y = rd(), scanf("%s", cc), z2 = cc[0] == 'V';
    if (x > y) swap(x, y), swap(z1, z2), z1 ^= 1, z2 ^= 1;
    ee[x][z1].push_back((ed){y, z2});
    zz[x] = zz[y] = 1;
  }
  scanf("%s", ss + 1), lc = strlen(ss + 1);
  for (int i = 1; i <= lc; ++i) an[i] = 127, nb[i] = -1;
  for (int i = 1; i <= lc + 1; ++i) {
    if (i > lc) {
      bool ok = 1;
      for (int j = 1; j <= lc; ++j)
        if (aa[j] != an[j]) {
          ok = aa[j] <= an[j];
          break;
        }
      if (ok) memcpy(an, aa, sizeof(aa));
      break;
    }
    bool f0 = 1, f1 = 1;
    int latp = tp;
    for (int j = ss[i] - 'a' + 1; j < l && (f0 || f1); ++j) {
      if (co[j] == 0 && f0) {
        f0 = 0;
        st[++tp][0] = i, st[tp][1] = nb[i], st[tp][2] = aa[i];
        nb[i] = -1, aa[i] = 0;
        if (st[tp][1] != 1 && putt(i, j) && dfs(i + 1)) break;
        while (tp > latp)
          nb[st[tp][0]] = st[tp][1], aa[st[tp][0]] = st[tp][2], --tp;
      } else if (co[j] == 1 && f1) {
        f1 = 0;
        st[++tp][0] = i, st[tp][1] = nb[i], st[tp][2] = aa[i];
        nb[i] = -1, aa[i] = 0;
        if (st[tp][1] != 0 && putt(i, j) && dfs(i + 1)) break;
        while (tp > latp)
          nb[st[tp][0]] = st[tp][1], aa[st[tp][0]] = st[tp][2], --tp;
      }
    }
    while (tp > latp)
      nb[st[tp][0]] = st[tp][1], aa[st[tp][0]] = st[tp][2], --tp;
    int lbb = nb[i];
    nb[i] = -1, aa[i] = 0;
    if (lbb == (co[ss[i] - 'a'] ^ 1) || !putt(i, ss[i] - 'a')) break;
  }
  if (an[1] <= 'z')
    printf("%s", an + 1);
  else
    puts("-1");
  return 0;
}
