#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
const int maxn = 210;
const int maxm = 500000 + 10;
struct Edge {
  int next, v;
  Edge() {}
  Edge(int next, int v) : next(next), v(v) {}
} e[maxm << 1];
int head[maxm], cnt;
int n, m, timer, num;
int low[maxn << 1], dfn[maxn << 1], bel[maxn << 1];
bool inst[maxn << 1], vis[maxn << 1];
int st[maxm], top;
inline int read() {
  int x = 0;
  char ch = getchar();
  while (ch < '0' || ch > '9') ch = getchar();
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x;
}
inline void AddEdge(int u, int v) {
  e[++cnt] = Edge(head[u], v);
  head[u] = cnt;
}
void tarjan(int u) {
  vis[u] = 1;
  low[u] = dfn[u] = ++timer;
  st[++top] = u;
  inst[u] = 1;
  for (int i = head[u]; i; i = e[i].next) {
    int v = e[i].v;
    if (!vis[v]) {
      tarjan(v);
      low[u] = min(low[u], low[v]);
    } else if (inst[v])
      low[u] = min(low[u], dfn[v]);
  }
  if (low[u] == dfn[u]) {
    num++;
    int j;
    do {
      j = st[top--];
      bel[j] = num;
      inst[j] = 0;
    } while (j != u);
  }
}
inline bool judge(int n) {
  for (int i = 2; i <= (n << 1 | 1); i++)
    if (!vis[i]) tarjan(i);
  for (int i = 2; i <= (n << 1); i += 2)
    if (bel[i] == bel[i + 1]) return 0;
  return 1;
}
char str[27];
char s[maxn], ans[maxn], tmp[maxn];
int w['z' + 2];
inline char get(int pos, char c) {
  for (int i = pos + 1; str[i] != '\0'; i++)
    if (str[i] == c) return 'a' + i;
  return -1;
}
int q[maxm], front, tail;
int main() {
  scanf("%s", str);
  int len = strlen(str);
  for (int i = 0; i < len; i++) w[i + 'a'] = str[i] == 'V' ? 0 : 1;
  n = read(), m = read();
  char s1[2], s2[2];
  int a, b;
  while (m--) {
    a = read(), scanf("%s", s1);
    b = read(), scanf("%s", s2);
    a = a << 1 | (s1[0] != 'V');
    b = b << 1 | (s2[0] != 'V');
    AddEdge(a, b);
    AddEdge(b ^ 1, a ^ 1);
  }
  scanf("%s", s + 1);
  if (!judge(n)) {
    puts("-1");
    return 0;
  }
  bool OK = 0;
  tmp[1] = -1;
  for (int pos = n + 1; pos >= 1; pos--) {
    for (int a = pos << 1; a <= (pos << 1 | 1); a++) {
      bool ok = 1;
      strcpy(ans + 1, s + 1);
      memset(vis, 0, sizeof(vis));
      if (pos <= n) {
        char tp = get(s[pos] - 'a', (a & 1) ? 'C' : 'V');
        if (tp == -1) continue;
        ans[pos] = tp;
      }
      for (int i = pos + 1; i <= n; i++) ans[i] = 'a';
      for (int i = 1; i <= n && ok; i++) {
        int a = i << 1 | w[ans[i]];
        if (vis[a]) continue;
        vis[a] = 1;
        front = tail = 0;
        q[++tail] = a;
        while (front != tail) {
          a = q[++front];
          if (vis[a ^ 1]) {
            ok = 0;
            break;
          }
          if (a / 2 <= pos && w[ans[a / 2]] != (a & 1)) {
            ok = 0;
            break;
          }
          if (a / 2 > pos) {
            char tp = get(-1, a & 1 ? 'C' : 'V');
            if (tp == -1) {
              ok = 0;
              break;
            }
            ans[a / 2] = tp;
          }
          for (int j = head[a]; j; j = e[j].next) {
            int v = e[j].v;
            if (!vis[v]) {
              vis[v] = 1;
              q[++tail] = v;
            }
          }
        }
      }
      if (!ok) continue;
      OK = 1;
      ans[n + 1] = 0;
      if (tmp[1] == -1)
        strcpy(tmp + 1, ans + 1);
      else if (strcmp(ans + 1, tmp + 1) < 0)
        strcpy(tmp + 1, ans + 1);
    }
    if (OK) break;
  }
  if (OK)
    puts(tmp + 1);
  else
    puts("-1");
  return 0;
}
