#include <bits/stdc++.h>
using namespace std;
namespace TYC {
const int N = 405;
int n, m, M, nxt[30][2];
int tim, top, scc, dfn[N], low[N], in[N], sta[N], bel[N];
char CH[30], S[N];
vector<int> E[N];
inline int id(const int i, const int j) { return i * 2 - j; }
void Tarjan(const int u) {
  dfn[u] = low[u] = ++tim;
  in[u] = 1;
  sta[++top] = u;
  for (int v : E[u])
    if (!dfn[v])
      Tarjan(v), low[u] = min(low[u], low[v]);
    else if (in[v])
      low[u] = min(low[u], dfn[v]);
  if (dfn[u] == low[u]) {
    scc++;
    int x;
    do {
      x = sta[top--];
      bel[x] = scc;
      in[x] = 0;
    } while (x != u);
  }
}
bool check() {
  tim = top = scc = 0;
  memset(dfn, 0, sizeof(int[n << 1 | 1]));
  memset(low, 0, sizeof(int[n << 1 | 1]));
  memset(in, 0, sizeof(int[n << 1 | 1]));
  memset(bel, 0, sizeof(int[n << 1 | 1]));
  for (int i = 1; i <= n << 1; i++)
    if (!dfn[i]) Tarjan(i);
  for (int i = 1; i <= n; i++)
    if (bel[id(i, 0)] == bel[id(i, 1)]) return false;
  return true;
}
bool check(const int k, const int t) {
  E[id(k, t ^ 1)].push_back(id(k, t));
  bool ans = check();
  E[id(k, t ^ 1)].pop_back();
  return ans;
}
void print(const int k, const int t, const int a, const int b) {
  for (int i = 1; i < k; i++) {
    putchar(S[i]);
    int c = CH[S[i] - 'a'] == 'C';
    E[id(i, c ^ 1)].push_back(id(i, c));
  }
  putchar(nxt[S[k] - 'a'][t] + 'a');
  E[id(k, t ^ 1)].push_back(id(k, t));
  for (int i = k + 1; i <= n; i++) {
    if (a < b) {
      if (check(i, 0))
        putchar(a + 'a'), E[id(i, 1)].push_back(id(i, 0));
      else
        putchar(b + 'a'), E[id(i, 0)].push_back(id(i, 1));
    } else {
      if (check(i, 1))
        putchar(b + 'a'), E[id(i, 0)].push_back(id(i, 1));
      else
        putchar(a + 'a'), E[id(i, 1)].push_back(id(i, 0));
    }
  }
  exit(0);
}
bool check_all() {
  for (int i = 1; i <= n; i++) {
    int t = CH[S[i] - 'a'] == 'C';
    E[id(i, t ^ 1)].push_back(id(i, t));
  }
  bool ans = check();
  for (int i = 1; i <= n; i++) E[id(i, CH[S[i] - 'a'] == 'V')].pop_back();
  return ans;
}
void work() {
  scanf("%s%d%d", CH, &n, &m);
  M = strlen(CH);
  int a = M, b = M;
  for (int i = M - 1; ~i; i--) {
    nxt[i][0] = a, nxt[i][1] = b;
    (CH[i] == 'V' ? a : b) = i;
  }
  char c1[5], c2[5];
  for (int i = 1, p1, p2; i <= m; i++) {
    scanf("%d%s%d%s", &p1, c1, &p2, c2);
    int t1 = c1[0] == 'C', t2 = c2[0] == 'C';
    E[id(p1, t1)].push_back(id(p2, t2));
    E[id(p2, t2 ^ 1)].push_back(id(p1, t1 ^ 1));
  }
  scanf("%s", S + 1);
  if (check_all()) {
    printf("%s", S + 1);
    return;
  } else if (a == M || b == M)
    return void(puts("-1"));
  for (int k = n; k; k--) {
    for (int i = 1; i < k; i++) {
      int t = CH[S[i] - 'a'] == 'C';
      E[id(i, t ^ 1)].push_back(id(i, t));
    }
    int v0 = nxt[S[k] - 'a'][0], v1 = nxt[S[k] - 'a'][1];
    if (v0 < v1) {
      if (v0 < M && check(k, 0))
        print(k, 0, a, b);
      else if (v1 < M && check(k, 1))
        print(k, 1, a, b);
    } else {
      if (v1 < M && check(k, 1))
        print(k, 1, a, b);
      else if (v0 < M && check(k, 0))
        print(k, 0, a, b);
    }
    for (int i = 1; i < k; i++) E[id(i, CH[S[i] - 'a'] == 'V')].pop_back();
  }
  puts("-1");
}
}  // namespace TYC
int main() {
  TYC::work();
  return 0;
}
