#include <bits/stdc++.h>
using namespace std;
const int M = 1e6 + 5;
const int N = 405;
int a[N], vi[N], b[30][2];
int n, m, k, now, v[M], nex[M], head[N];
void addedges(int x, int y) {
  nex[++now] = head[x];
  head[x] = now, v[now] = y;
}
char s[N];
bool dfs(int x) {
  if (vi[x > n ? x - n : x + n]) return 0;
  vi[x] = 1;
  for (int i = head[x]; i; i = nex[i])
    if (!vi[v[i]] && !dfs(v[i])) return 0;
  return 1;
}
bool check(int d) {
  for (int i = 1; i <= n * 2; i++) vi[i] = 0;
  for (int i = 1; i <= d; i++)
    if (!dfs(i + a[s[i] - 'a'] * n)) return 0;
  for (int i = d + 1; i <= n; i++) {
    if (vi[i] && b[0][0] != k)
      s[i] = b[0][0] + 'a';
    else if (vi[i + n] && b[0][1] != k)
      s[i] = b[0][1] + 'a';
    else {
      int x = min(b[0][0], b[0][1]), y = max(b[0][0], b[0][1]);
      if (x != k && dfs(i + (b[0][0] > b[0][1]) * n))
        s[i] = x + 'a';
      else if (y != k && dfs(i + (b[0][0] < b[0][1]) * n))
        s[i] = y + 'a';
      else
        puts("-1"), exit(0);
    }
  }
  return 1;
}
int main() {
  scanf("%s", s);
  k = strlen(s);
  for (int i = k - 1, t[2] = {k, k}; ~i; i--)
    t[a[i] = (s[i] == 'C')] = i, b[i][0] = t[0], b[i][1] = t[1];
  scanf("%d%d", &n, &m);
  while (m--) {
    int x1, y1, x2, y2;
    scanf("%d %s", &x1, s);
    if (s[0] == 'V')
      x2 = x1 + n;
    else
      x2 = x1, x1 += n;
    scanf("%d %s", &y1, s);
    if (s[0] == 'V')
      y2 = y1 + n;
    else
      y2 = y1, y1 += n;
    addedges(x1, y1), addedges(y2, x2);
  }
  scanf("%s", s + 1);
  if (check(n)) return printf("%s\n", s + 1), 0;
  for (int i = n; i; i--) {
    int c = s[i] - 'a' + 1, x = min(b[c][0], b[c][1]),
        y = max(b[c][0], b[c][1]);
    if (c == k) continue;
    if (x != k) {
      s[i] = x + 'a';
      if (check(i)) return printf("%s\n", s + 1), 0;
    }
    if (y != k) {
      s[i] = y + 'a';
      if (check(i)) return printf("%s\n", s + 1), 0;
    }
  }
  return puts("-1"), 0;
}
