#include <bits/stdc++.h>
using namespace std;
const int MAXN = 202;
int N, M, s[MAXN], cs[MAXN], alS;
char ss[MAXN], al[30];
int f(int l) { return al[l] == 'V' ? 0 : 1; }
int vgt[30], cgt[30], minv, minc;
vector<int> G[MAXN * 2];
bool vis[MAXN * 2];
void dfs(int v) {
  vis[v] = true;
  for (int i = 0; i < G[v].size(); i++) {
    int u = G[v][i];
    if (!vis[u]) dfs(u);
  }
}
bool good() {
  for (int i = 0; i < N; i++)
    if (vis[i] && vis[i + N]) {
      return false;
    }
  return true;
}
int main() {
  scanf("%s", al);
  alS = strlen(al);
  scanf("%d", &N), scanf("%d", &M);
  int vm = alS, cm = alS;
  for (int i = alS; i > -1; i--) {
    vgt[i] = vm;
    cgt[i] = cm;
    if (f(i))
      cm = i;
    else
      vm = i;
  }
  minv = vm;
  minc = cm;
  for (int i = 0; i < 2 * N; i++) G[i].clear();
  for (int i = 0; i < M; i++) {
    int p1, p2, t1, t2;
    char tt1[2], tt2[2];
    scanf("%d%s%d%s", &p1, tt1, &p2, tt2);
    p1--;
    p2--;
    t1 = tt1[0] == 'C';
    t2 = tt2[0] == 'C';
    G[p1 + N * t1].push_back(p2 + N * t2);
    G[p2 + N * (1 - t2)].push_back(p1 + N * (1 - t1));
  }
  scanf("%s", ss);
  for (int i = 0; i < N; i++) s[i] = cs[i] = ss[i] - 'a';
  for (int i = 0; i < N; i++)
    if (!vis[i + N * f(s[i])]) {
      dfs(i + N * f(s[i]));
    }
  if (good()) {
    printf("%s\n", ss);
    return 0;
  }
  bool found = false;
  for (int n = N - 1; n > -1 && !found; n--) {
    int next[2];
    next[0] = min(vgt[s[n]], cgt[s[n]]);
    next[1] = max(vgt[s[n]], cgt[s[n]]);
    for (int j = 0; j < 2 && !found; j++) {
      if (next[j] == alS) continue;
      cs[n] = next[j];
      memset(vis, false, sizeof(bool) * (2 * N));
      for (int i = 0; i < n + 1; i++)
        if (!vis[i + N * f(cs[i])]) dfs(i + N * f(cs[i]));
      if (good()) {
        found = true;
        for (int i = n + 1; i < N; i++) {
          if (vis[i] && vis[i + N]) {
            found = false;
            break;
          } else if (vis[i]) {
            if (minv == alS) {
              found = false;
              break;
            }
            cs[i] = minv;
          } else if (vis[i + N]) {
            if (minc == alS) {
              found = false;
              break;
            }
            cs[i] = minc;
          } else {
            if (minv < minc) {
              cs[i] = minv;
              dfs(i);
            } else if (minc != alS) {
              cs[i] = minc;
              dfs(i + N);
            } else {
              found = false;
              break;
            }
          }
        }
      }
    }
  }
  if (!found)
    printf("-1\n");
  else {
    for (int i = 0; i < N; i++) ss[i] = cs[i] + 'a';
    printf("%s\n", ss);
  }
}
