#include <bits/stdc++.h>
using namespace std;
const int N = 405, inf = 0x3f3f3f3f;
int read() {
  int f = 1, g = 0;
  char ch = getchar();
  for (; !isdigit(ch); ch = getchar())
    if (ch == '-') f = -1;
  for (; isdigit(ch); ch = getchar()) g = g * 10 + ch - '0';
  return f * g;
}
int L, n, m, typ[N];
char ch[N], s[N], ans[N];
namespace g {
int cnt, h[N], bel[N], dfn[N], low[N], top, stk[N];
vector<int> e[N];
void add(int x, char c, int y, char d) {
  x = (x * 2) ^ (c == 'V');
  y = (y * 2) ^ (d == 'V');
  e[x].push_back(y);
  e[y ^ 1].push_back(x ^ 1);
}
void del(int x, char c, int y, char d) {
  x = (x * 2) ^ (c == 'V');
  y = (y * 2) ^ (d == 'V');
  e[x].pop_back();
  e[y ^ 1].pop_back();
}
void tarjan(int x) {
  h[x] = 1;
  stk[++top] = x;
  dfn[x] = low[x] = ++cnt;
  for (auto y : e[x])
    if (!h[y]) {
      tarjan(y);
      low[x] = min(low[x], low[y]);
    } else if (h[y] == 1)
      low[x] = min(low[x], dfn[y]);
  if (dfn[x] == low[x]) {
    while (stk[top] != x) {
      h[stk[top]] = 2;
      bel[stk[top--]] = x;
    }
    h[stk[top]] = 2;
    bel[stk[top--]] = x;
  }
}
bool check() {
  cnt = top = 0;
  memset(h, 0, sizeof(h));
  for (int i = 2; i <= n * 2 + 1; i++)
    if (!h[i]) tarjan(i);
  for (int i = 1; i <= n; i++)
    if (bel[i * 2] == bel[i * 2 + 1]) return false;
  return true;
}
};  // namespace g
bool chk(int len) {
  if (len == n) return g::check();
  int i = len + 1, fl = 0;
  for (int c = s[i] - 'a' + 1; c < L; c++) {
    if (fl & (1 << typ[c])) continue;
    fl += (1 << typ[c]);
    g::add(i, 'V' + 'C' - ch[c], i, ch[c]);
    if (g::check()) {
      ans[i] = 'a' + c;
      return true;
    }
    g::del(i, 'V' + 'C' - ch[c], i, ch[c]);
  }
  return false;
}
void getans() {
  int i;
  for (i = 1; i <= n; i++)
    g::add(i, 'V' + 'C' - ch[s[i] - 'a'], i, ch[s[i] - 'a']), ans[i] = s[i];
  for (i = n; i; i--) {
    if (chk(i)) break;
    g::del(i, 'V' + 'C' - ch[s[i] - 'a'], i, ch[s[i] - 'a']);
  }
  if (!chk(i)) {
    puts("-1");
    exit(0);
  }
  for (i = i + 2; i <= n; i++) {
    int fl = 0;
    for (int c = 0; c < L; c++) {
      if (fl & (1 << typ[c])) continue;
      fl += (1 << typ[c]);
      g::add(i, 'V' + 'C' - ch[c], i, ch[c]);
      if (g::check()) {
        ans[i] = 'a' + c;
        fl += 4;
        break;
      }
      g::del(i, 'V' + 'C' - ch[c], i, ch[c]);
    }
    if (!(fl & 4)) {
      puts("-1");
      exit(0);
    }
  }
}
int main() {
  scanf(" %s %d %d", ch, &n, &m);
  L = strlen(ch);
  for (int i = 0; i < L; i++) typ[i] = (ch[i] == 'V');
  for (int i = 1; i <= m; i++) {
    int x, y;
    char c, d;
    scanf("%d %c %d %c", &x, &c, &y, &d);
    g::add(x, c, y, d);
  }
  scanf(" %s", s + 1);
  getans();
  printf("%s\n", ans + 1);
  return 0;
}
