#include <bits/stdc++.h>
using namespace std;
const int N = 444;
const int M = 2e5 + 10;
struct SCC {
  int n, m;
  vector<int> g[N], rg[N], vs;
  bool vis[N];
  int mk[N];
  void init(int _n) {
    n = _n;
    m = 0;
    for (int i = 1; i <= n; ++i) {
      g[i].clear();
      rg[i].clear();
      vis[i] = 0;
      mk[i] = 0;
    }
    vs.clear();
  }
  void add(int u, int v) {
    g[u].push_back(v);
    rg[v].push_back(u);
  }
  void dfs(int u) {
    vis[u] = 1;
    for (int v : g[u])
      if (!vis[v]) dfs(v);
    vs.push_back(u);
  }
  void rdfs(int u, int c) {
    vis[u] = 1;
    mk[u] = c;
    for (int v : rg[u])
      if (!vis[v]) rdfs(v, c);
  }
  void solve() {
    vs.clear();
    fill(vis, vis + 1 + n, 0);
    for (int i = 1; i <= n; ++i)
      if (!vis[i]) dfs(i);
    fill(vis, vis + 1 + n, 0);
    reverse(vs.begin(), vs.end());
    for (int u : vs)
      if (!vis[u]) rdfs(u, ++m);
  }
};
int l, n, m;
int typ[33];
char ip[N];
inline int nxt(int c, int tp) {
  for (int i = c; i < l; ++i)
    if (typ[i] == tp) return i;
  return -1;
}
inline int neg(int i) {
  if (i <= n)
    return i + n;
  else
    return i - n;
}
struct SAT2 {
  SCC scc;
  int cnt[N];
  int cntr[N];
  void init() { scc.init(n + n); }
  void _init() {
    for (int i = 1; i <= n + n; ++i) {
      scc.g[i].resize(scc.g[i].size() - cnt[i]);
      scc.rg[i].resize(scc.rg[i].size() - cntr[i]);
    }
    fill(cnt, cnt + n + n + 1, 0);
    fill(cntr, cntr + n + n + 1, 0);
  }
  void add2(int x, int y) {
    cnt[x]++;
    cntr[y]++;
    cnt[neg(y)]++;
    cntr[neg(x)]++;
    scc.add(x, y);
    scc.add(neg(y), neg(x));
  }
  void add(int x, int y) {
    scc.add(x, y);
    scc.add(neg(y), neg(x));
  }
  bool solve() {
    scc.solve();
    for (int i = 1; i <= n; ++i)
      if (scc.mk[i] == scc.mk[neg(i)]) return 0;
    return 1;
  }
} twosat;
int p1[M], p2[M];
void init() {
  char buf[33];
  scanf("%s%d%d", buf, &n, &m);
  l = strlen(buf);
  for (int c = 0; c < l; ++c) typ[c] = (buf[c] == 'V');
  for (int i = 0; i < m; ++i) {
    int u, v;
    char t1[2], t2[2];
    scanf("%d%s%d%s", &u, t1, &v, t2);
    if (t1[0] != 'V') u = neg(u);
    if (t2[0] != 'V') v = neg(v);
    p1[i] = u, p2[i] = v;
  }
  scanf("%s", ip + 1);
}
bool chk() {
  twosat._init();
  for (int i = 1; i <= n; ++i) {
    if (ip[i]) {
      int c = ip[i] - 'a';
      if (typ[c]) {
        twosat.add2(neg(i), i);
      } else {
        twosat.add2(i, neg(i));
      }
    }
  }
  return twosat.solve();
}
void mini(int i) {
  for (int j = i + 1; j <= n; ++j) {
    int c0 = nxt(0, 0), c1 = nxt(0, 1);
    if (c0 > c1) swap(c0, c1);
    if (c0 != -1) {
      ip[j] = 'a' + c0;
      if (chk()) continue;
    }
    if (c1 != -1) {
      ip[j] = 'a' + c1;
      if (chk()) continue;
    }
    puts("-1");
    exit(0);
  }
  printf("%s\n", ip + 1);
  exit(0);
}
void solve() {
  twosat.init();
  for (int i = 0; i < m; ++i) {
    twosat.add(p1[i], p2[i]);
  }
  if (chk()) {
    printf("%s\n", ip + 1);
    return;
  }
  for (int i = n; i > 0; --i) {
    int cc = ip[i] - 'a';
    int c0 = nxt(cc + 1, 0), c1 = nxt(cc + 1, 1);
    if (c0 > c1) swap(c0, c1);
    if (c0 != -1) {
      ip[i] = 'a' + c0;
      if (chk()) mini(i);
    }
    if (c1 != -1) {
      ip[i] = 'a' + c1;
      if (chk()) mini(i);
    }
    ip[i] = 0;
  }
  puts("-1");
}
int main() {
  init();
  solve();
}
