#include <bits/stdc++.h>
using namespace std;
int n, m, nex[2][215], alp[215], str[215], lim[160015][4];
void init() {
  char s[215];
  scanf("%s", s + 1);
  memset(nex, -1, sizeof(nex));
  for (int i = strlen(s + 1); i >= 1; --i)
    if (alp[i] = (s[i] == 'V')) {
      nex[1][i] = i;
      nex[0][i] = nex[0][i + 1];
    } else {
      nex[0][i] = i;
      nex[1][i] = nex[1][i + 1];
    }
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= m; ++i) {
    int u, v;
    char su[2], sv[2];
    scanf("%d%s%d%s", &u, su, &v, sv);
    lim[i][0] = u;
    lim[i][1] = (su[0] == 'V');
    lim[i][2] = v;
    lim[i][3] = (sv[0] == 'V');
  }
  scanf("%s", s + 1);
  for (int i = 1; i <= n; ++i) str[i] = s[i] - 'a' + 1;
  bool ok = 1;
  for (int i = 1; i <= m; ++i)
    if (alp[str[lim[i][0]]] == lim[i][1] && alp[str[lim[i][2]]] != lim[i][3]) {
      ok = 0;
      break;
    }
  if (ok) {
    puts(s + 1);
    exit(0);
  }
}
struct Tsat {
  int tot, now[415], pre[400015], fa[400015], son[400015];
  int V(int x, int t) { return t * n + x; }
  void clear() {
    tot = 1;
    memset(now, 0, sizeof(now));
  }
  void erase_last() {
    now[fa[tot]] = pre[now[fa[tot]]];
    --tot;
  }
  void connect(int x, int tx, int y, int ty) {
    x = V(x, tx);
    y = V(y, ty);
    pre[++tot] = now[x];
    now[x] = tot;
    fa[tot] = x;
    son[tot] = y;
  }
  bool ins[415];
  int tim, top, scc, dfn[415], low[415], stk[415], bel[415];
  void tarjan(int u) {
    dfn[u] = low[u] = ++tim;
    stk[++top] = u;
    ins[u] = 1;
    for (int p = now[u]; p; p = pre[p])
      if (!dfn[son[p]]) {
        tarjan(son[p]);
        low[u] = min(low[u], low[son[p]]);
      } else if (ins[son[p]])
        low[u] = min(low[u], dfn[son[p]]);
    if (low[u] == dfn[u]) {
      ++scc;
      int p;
      do {
        p = stk[top--];
        ins[p] = 0;
        bel[p] = scc;
      } while (p != u);
    }
  }
  bool check() {
    scc = tim = top = 0;
    memset(ins, 0, sizeof(ins));
    memset(dfn, 0, sizeof(dfn));
    for (int i = 1; i <= n << 1; ++i)
      if (!dfn[i]) tarjan(i);
    for (int i = 1; i <= n; ++i)
      if (bel[V(i, 0)] == bel[V(i, 1)]) return 0;
    return 1;
  }
} sat;
int ans[215];
void work() {
  sat.clear();
  for (int i = 1; i <= n; ++i) {
    if (nex[0][1] == -1) sat.connect(i, 0, i, 1);
    if (nex[1][1] == -1) sat.connect(i, 1, i, 0);
  }
  for (int i = 1; i <= m; ++i) {
    sat.connect(lim[i][0], lim[i][1], lim[i][2], lim[i][3]);
    sat.connect(lim[i][2], !lim[i][3], lim[i][0], !lim[i][1]);
  }
  int k, alp_k = -1;
  for (k = n; k >= 1; --k) {
    vector<int> t;
    if (nex[0][str[k] + 1] != -1) t.push_back(nex[0][str[k] + 1]);
    if (nex[1][str[k] + 1] != -1) t.push_back(nex[1][str[k] + 1]);
    sort(t.begin(), t.end());
    for (int i = 1; i < k; ++i) sat.connect(i, !alp[str[i]], i, alp[str[i]]);
    for (unsigned i = 0; i < t.size(); ++i) {
      sat.connect(k, !alp[t[i]], k, alp[t[i]]);
      bool can = sat.check();
      sat.erase_last();
      if (can) {
        alp_k = alp[t[i]];
        break;
      }
    }
    for (int i = 1; i < k; ++i) sat.erase_last();
    if (alp_k != -1) break;
  }
  if (!k) {
    puts("-1");
    return;
  }
  for (int i = 1; i < k; ++i) ans[i] = str[i];
  ans[k] = nex[alp_k][str[k] + 1];
  for (++k; k <= n; ++k) {
    int t = 0;
    if (nex[0][1] == -1 || (nex[1][1] != -1 && nex[1][1] < nex[0][1])) t = 1;
    for (int i = 1; i < k; ++i) sat.connect(i, !alp[ans[i]], i, alp[ans[i]]);
    sat.connect(k, !t, k, t);
    if (sat.check())
      ans[k] = nex[t][1];
    else
      ans[k] = nex[!t][1];
    for (int i = 1; i <= k; ++i) sat.erase_last();
  }
  for (int i = 1; i <= n; ++i) putchar('a' + ans[i] - 1);
  putchar('\n');
}
int main() {
  init();
  work();
  return 0;
}
