#include <bits/stdc++.h>
using namespace std;
const int inft = 1000000009;
const int MAXN = 406;
char LIT[30];
vector<int> VIN[MAXN];
vector<int> V[MAXN];
char S[MAXN];
bool typ(char a) { return LIT[a - 'a'] == 'V'; }
int n;
int tin[MAXN], ct;
vector<int> Q;
int scc[MAXN], SCC;
void przetworz(vector<int> &R) {
  ++SCC;
  for (typeof((R).begin()) it = (R).begin(); it != (R).end(); ++it)
    scc[*it] = SCC;
}
int dfs(int u) {
  tin[u] = ct++;
  Q.push_back(u);
  int m = tin[u];
  for (typeof((V[u]).begin()) it = (V[u]).begin(); it != (V[u]).end(); ++it)
    if (scc[*it] == -1) {
      if (tin[*it] != -1)
        m = min(m, tin[*it]);
      else
        m = min(m, dfs(*it));
    }
  if (m == tin[u]) {
    vector<int> R;
    do {
      R.push_back(Q.back());
      Q.pop_back();
    } while (R.back() != u);
    przetworz(R);
  }
  return m;
}
bool dasie() {
  ;
  for (int i = 0; i < (2 * n); ++i) V[i] = VIN[i];
  for (int i = 0; i < (n); ++i)
    if (S[i] != '$') {
      int q = 2 * i + typ(S[i]);
      V[q ^ 1].push_back(q);
      ;
    };
  for (int i = 0; i < (2 * n); ++i) scc[i] = tin[i] = -1;
  SCC = 0;
  ct = 0;
  for (int i = 0; i < (2 * n); ++i)
    if (tin[i] == -1) dfs(i);
  for (int i = 0; i < (n); ++i)
    if (scc[2 * i] == scc[2 * i + 1]) return 0;
  return 1;
}
int main() {
  int m;
  scanf("%s %d%d", LIT, &n, &m);
  int alf = strlen(LIT);
  for (int i = 0; i < (m); ++i) {
    int a, b;
    char t1, t2;
    scanf("%d %c %d %c", &a, &t1, &b, &t2);
    --a;
    --b;
    a *= 2;
    b *= 2;
    a += t1 == 'V';
    b += t2 == 'V';
    V[a].push_back(b);
    V[b ^ 1].push_back(a ^ 1);
  }
  bool ktos[2] = {0, 0};
  for (int i = 0; i < (alf); ++i) ktos[typ(i + 'a')] = 1;
  for (int i = 0; i < (2); ++i)
    if (ktos[i] == 0) {
      for (int j = 0; j < (n); ++j) V[2 * j + i].push_back(2 * j + 1 - i);
    }
  for (int i = 0; i < (2 * n); ++i) VIN[i] = V[i];
  for (int i = 0; i < (2 * n); ++i)
    for (typeof((V[i]).begin()) it = (V[i]).begin(); it != (V[i]).end(); ++it)
      ;
  scanf("%s", S);
  if (dasie()) {
    printf("%s\n", S);
    return 0;
  }
  for (int i = n - 1; i >= 0; --i) {
    char tu = S[i];
    S[i] = '$';
    if (dasie()) {
      bool byl[2] = {0, 0};
      for (int j = 0; j < (alf); ++j)
        if (j + 'a' > tu && !byl[typ(j + 'a')]) {
          S[i] = j + 'a';
          byl[typ(j + 'a')] = 1;
          if (dasie()) {
            for (++i; i < n; ++i) {
              for (int k = 0; k < (2); ++k) byl[k] = 0;
              bool ok = 0;
              for (int jj = 0; jj < (alf); ++jj)
                if (!byl[typ(jj + 'a')]) {
                  byl[typ(jj + 'a')] = 1;
                  S[i] = jj + 'a';
                  if (dasie()) {
                    ok = 1;
                    break;
                  }
                }
              assert(ok);
            }
            printf("%s\n", S);
            return 0;
          }
        }
    }
    S[i] = '$';
  }
  printf("-1\n");
  return 0;
}
