#include <bits/stdc++.h>
using namespace std;
const int N = 800;
const long long MOD = 1e9 + 7;
int n, m, l, idx[N], low[N], comp[N], compID[N], cmp, cnt, val[N];
bool is_vowel[26], vow[N], vis[N];
char s[N];
stack<int> S;
vector<vector<char> > c;
vector<vector<int> > g;
vector<pair<pair<int, bool>, pair<int, bool> > > v;
inline int Not(int u) { return u >= 2 * n ? u - 2 * n : u + 2 * n; }
inline void add(int a, int b) {
  g[Not(a)].push_back(b);
  g[Not(b)].push_back(a);
}
inline void remove(int a, int b) {
  g[Not(a)].pop_back();
  g[Not(b)].pop_back();
}
void clear() {
  memset(idx, 0, sizeof idx);
  memset(val, -1, sizeof val);
  cmp = cnt = 0;
  g.clear();
  g.resize(4 * n);
  for (int i = 0; i < n; ++i) {
    add(2 * i, 2 * i + 1);
    add(Not(2 * i), Not(2 * i + 1));
  }
  for (int i = 0; i < m; ++i)
    add(Not(v[i].first.first * 2 + (!v[i].first.second)),
        v[i].second.first * 2 + (!v[i].second.second));
}
void clear2() {
  memset(idx, 0, sizeof idx);
  memset(val, -1, sizeof val);
  cmp = cnt = 0;
}
void dfs(int u) {
  idx[u] = low[u] = ++cnt;
  vis[u] = 1;
  S.push(u);
  for (int i = 0; i < g[u].size(); ++i) {
    int v = g[u][i];
    if (!idx[v]) dfs(v);
    if (vis[v]) low[u] = min(low[u], low[v]);
  }
  if (idx[u] == low[u]) {
    while (1) {
      int v = S.top();
      S.pop();
      vis[v] = 0;
      comp[v] = cmp;
      if (v == u) break;
    }
    compID[cmp++] = u;
  }
}
bool check(int len) {
  for (int i = 0; i < 4 * n; ++i)
    if (!idx[i]) dfs(i);
  for (int i = 0; i < 2 * n; ++i)
    if (comp[i] == comp[Not(i)]) return 0;
  for (int i = 0; i < cmp; ++i)
    if (val[i] == -1) {
      val[i] = 1;
      val[comp[Not(compID[i])]] = 0;
    }
  return 1;
}
int main() {
  char tmp[27];
  scanf("%s", tmp);
  l = strlen(tmp);
  c.resize(2);
  for (int i = 0; i < l; ++i) {
    is_vowel[i] = tmp[i] == 'V';
    if (tmp[i] == 'V')
      c[1].push_back(char(i + 'a'));
    else
      c[0].push_back(char(i + 'a'));
  }
  scanf("%d%d", &n, &m);
  for (int i = 0; i < m; ++i) {
    int a, b;
    char c1, c2;
    scanf("%d %c%d %c", &a, &c1, &b, &c2);
    a--, b--;
    v.push_back(make_pair(make_pair(a, c1 == 'V'), make_pair(b, c2 == 'V')));
  }
  scanf("%s", s);
  for (int i = 0; i < n; ++i) vow[i] = is_vowel[s[i] - 'a'];
  for (int i = n - 1; i >= -1; --i) {
    clear();
    string t = "";
    for (int j = 0; j <= i; ++j) {
      t += s[j];
      add(2 * j + (!vow[j]), 2 * j + (!vow[j]));
    }
    if (check(i + 1)) {
      string ans = "";
      for (int j = 0; j <= i; ++j) ans += s[j];
      for (int j = 0; j < ans.size(); ++j)
        add(2 * j + (!vow[j]), 2 * j + (!vow[j]));
      for (int j = i + 1; j < n; ++j) {
        char mn = 'z' + 1;
        for (int j2 = 0; j2 < 2; ++j2) {
          if (int k = j == i + 1
                          ? upper_bound(c[j2].begin(), c[j2].end(), s[j]) -
                                c[j2].begin()
                          : 0,
              u = 2 * j + (!j2);
              k < c[j2].size()) {
            ans += c[j2][k];
            clear2();
            add(u, u);
            if (check(j + 1)) mn = min(mn, c[j2][k]);
            remove(u, u);
            ans.pop_back();
          }
        }
        if (mn > 'z')
          break;
        else {
          ans += mn;
          add(2 * j + (!is_vowel[mn - 'a']), 2 * j + (!is_vowel[mn - 'a']));
        }
      }
      if (ans.size() == n) {
        puts(ans.c_str());
        return 0;
      }
    }
  }
  puts("-1");
  return 0;
}
