#include <bits/stdc++.h>
int n, m, len, sta;
bool find, mp[405][405];
char table[30], s[205], ans[205];
int inv(const int &t) { return t < n ? t + n : t - n; }
int get(const char &c) { return c == 'V' ? 1 : 2; }
void print(int t, bool any) {
  if (t == n) return void((find = true, puts(ans)));
  for (char i = any ? 'a' : s[t]; i < 'a' + len; ++i) {
    ans[t] = i;
    for (int j = 0, n1, n2; j < t; ++j) {
      n1 = j + (get(table[ans[j] - 'a']) - 1) * n,
      n2 = t + (get(table[ans[t] - 'a']) - 1) * n;
      if (mp[n1][inv(n2)] || mp[n2][inv(n1)]) goto illegal;
    }
    print(t + 1, any || i > s[t]);
    if (find) return;
  illegal:;
  }
}
int main() {
  scanf("%s%d%d", table, &n, &m), len = strlen(table);
  for (int i = 0; i < len; ++i) sta |= get(table[i]);
  if (sta < 3)
    for (int i = 0; i < n; ++i) {
      if (sta == 1)
        mp[inv(i)][i] = 1;
      else
        mp[i][inv(i)] = 1;
    }
  for (int i = 0; i < m; ++i) {
    int p1, p2;
    char t1, t2;
    scanf("%d %c%d %c", &p1, &t1, &p2, &t2), --p1, --p2;
    if (t1 == 'C') p1 = inv(p1);
    if (t2 == 'C') p2 = inv(p2);
    mp[p1][p2] = mp[inv(p2)][inv(p1)] = 1;
  }
  scanf("%s", s);
  for (int k = 0; k < n << 1; ++k)
    for (int i = 0; i < n << 1; ++i)
      for (int j = 0; j < n << 1; ++j) mp[i][j] |= mp[i][k] && mp[k][j];
  for (int i = 0; i < n << 1; ++i)
    if (mp[i][inv(i)] && mp[inv(i)][i]) return puts("-1"), 0;
  return print(0, 0), !find && puts("-1"), 0;
}
