#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1.0);
const double eps = 1e-11;
template <class T>
T sqr(const T &x) {
  return x * x;
}
template <class T>
T lowbit(const T &x) {
  return (x ^ (x - 1)) & x;
}
template <class T>
int countbit(const T &n) {
  return (n == 0) ? 0 : (1 + countbit(n & (n - 1)));
}
template <class T>
void ckmin(T &a, const T &b) {
  if (b < a) a = b;
}
template <class T>
void ckmax(T &a, const T &b) {
  if (b > a) a = b;
}
int h;
char z[500];
int n, m;
int n2;
bool g[500][500];
bool d[500][500];
char w[500];
int anti(int p) { return (p < n) ? (p + n) : (p - n); }
bool solve(int pos, char c) {
  int s = pos, t = pos + n;
  if (z[c - 'a'] == 'V') swap(s, t);
  for (int i = 0; i < (n); ++i)
    if ((g[i][i + n] || g[i][s] && g[t][i + n]) &&
        (g[i + n][i] || g[i + n][s] && g[t][i]))
      return false;
  return true;
}
void update(int pos, char c) {
  int s = pos, t = pos + n;
  if (z[c - 'a'] == 'V') swap(s, t);
  for (int i = 0; i < (n2); ++i)
    if (g[i][s])
      for (int j = 0; j < (n2); ++j)
        if (g[t][j]) g[i][j] = true;
}
int main() {
  std::ios_base::sync_with_stdio(false);
  cin >> z;
  h = strlen(z);
  cin >> n >> m;
  n2 = n + n;
  memset(g, false, sizeof(g));
  for (int i = 0; i < (n2); ++i) g[i][i] = true;
  for (int cl = 0; cl < (m); ++cl) {
    int p1, p2;
    char e1[10], e2[10];
    cin >> p1 >> e1 >> p2 >> e2;
    --p1;
    --p2;
    if (e1[0] == 'C') p1 += n;
    if (e2[0] == 'C') p2 += n;
    g[p1][p2] = true;
    g[anti(p2)][anti(p1)] = true;
  }
  bool h0 = false, h1 = false;
  for (int i = 0; i < (h); ++i)
    if (z[i] == 'V')
      h0 = true;
    else
      h1 = true;
  if (!h0)
    for (int i = 0; i < (n); ++i) g[i][i + n] = true;
  if (!h1)
    for (int i = 0; i < (n); ++i) g[i + n][i] = true;
  for (int k = 0; k < (n2); ++k)
    for (int i = 0; i < (n2); ++i)
      for (int j = 0; j < (n2); ++j)
        if (g[i][k] && g[k][j]) g[i][j] = true;
  bool ok = true;
  for (int k = 0; k < (n); ++k)
    if (g[k][n + k] && g[n + k][k]) ok = false;
  if (!ok) {
    printf("-1\n");
    return 0;
  }
  memcpy(d, g, sizeof(d));
  cin >> w;
  int last_at = -1;
  char last_c = 0;
  for (int i = 0; i < (n); ++i) {
    for (char c = w[i] + (int)(i < n - 1); c < 'a' + h; c++)
      if (solve(i, c)) {
        last_at = i;
        last_c = c;
        break;
      }
    update(i, w[i]);
  }
  if (last_at < 0) {
    printf("-1\n");
    return 0;
  }
  memcpy(g, d, sizeof(g));
  for (int i = 0; i < (last_at); ++i) update(i, w[i]);
  w[last_at] = last_c;
  update(last_at, last_c);
  for (int i = (last_at + 1); i < (n); ++i)
    for (char c = 'a'; c < 'a' + h; c++)
      if (solve(i, c)) {
        update(i, c);
        w[i] = c;
        break;
      }
  printf("%s\n", w);
  return 0;
}
