#include <bits/stdc++.h>
using namespace std;
const long long N = 500 + 10, MOD = 1e9 + 7, V = 727;
vector<int> adj[N], vec1[N], vec2[N], nw;
int n, m, ans[N], f[2] = {100, 100};
bool se[N], l[N], o1, o2;
string vc, s, res;
bool setc(int v, bool r) {
  vector<int> ms;
  if (!r) swap(vec2[v], vec1[v]);
  for (int i = 0; i < vec1[v].size(); i++) {
    int u = vec1[v][i];
    bool t;
    if (!r)
      t = 1 - u % 2;
    else
      t = u % 2;
    if (ans[u / 2] != t && ans[u / 2] != -1) return false;
    if (ans[u / 2] == -1) {
      ans[u / 2] = t;
      nw.push_back(u / 2);
      int tmp = (u / 2) * 2;
      ms.push_back(tmp + t);
    }
  }
  if (!r) swap(vec2[v], vec1[v]);
  if (r) setc(v ^ 1, !r);
  for (int i = 0; i < ms.size(); i++) setc(ms[i], 1);
  return true;
}
void dfs(int v, int S) {
  vec2[v].push_back(S);
  vec1[S].push_back(v);
  se[v] = 1;
  for (int i = 0; i < adj[v].size(); i++)
    if (!se[adj[v][i]]) dfs(adj[v][i], S);
}
bool check(int t) {
  if (t == n) return 1;
  if (ans[t] != -1 && f[ans[t]] != 100) {
    res += 'a' + f[ans[t]];
    return check(t + 1);
  }
  nw.clear();
  if (setc(2 * t + o1, 1)) {
    res += 'a' + f[o1];
    return check(t + 1);
  }
  for (int i = 0; i < nw.size(); i++) ans[nw[i]] = -1;
  if (f[o2] != 100 && setc(2 * t + o2, 1)) {
    res += 'a' + f[o2];
    return check(t + 1);
  }
  return 0;
}
bool check2(int ind) {
  bool ca = 1;
  for (int j = 0; j < ind; j++) {
    if (!setc(j * 2 + l[s[j] - 'a'], 1)) {
      ca = 0;
      break;
    }
  }
  return ca;
}
int main() {
  cin >> vc;
  for (int i = 0; i < vc.size(); i++) {
    l[i] = (vc[i] == 'V');
    if (vc[i] == 'V')
      f[1] = min(f[1], i);
    else
      f[0] = min(f[0], i);
  }
  if (f[1] < f[0])
    o1 = 1, o2 = 0;
  else
    o1 = 0, o2 = 1;
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int a, b;
    char ta, tb;
    cin >> a >> ta >> b >> tb;
    a--, b--;
    a *= 2, b *= 2;
    a += (ta == 'V');
    b += (tb == 'V');
    adj[a].push_back(b);
  }
  cin >> s;
  for (int i = 0; i < 2 * n; i++) {
    fill(se, se + N, 0);
    dfs(i, i);
  }
  fill(ans, ans + N, -1);
  if (check2(n)) return cout << s, 0;
  for (int i = n - 1; i >= 0; i--) {
    res.clear();
    int lc = 100, lv = 100;
    for (int k = s[i] - 'a' + 1; k < vc.size(); k++) {
      if (l[k] == 0) lc = min(lc, k);
      if (l[k] == 1) lv = min(lv, k);
    }
    bool ff = 0, ss = 1;
    if (lv < lc) {
      swap(ff, ss);
      swap(lc, lv);
    }
    for (int j = 0; j < i; j++) res += s[j];
    if (lc != 100) {
      fill(ans, ans + N, -1);
      if (setc(i * 2 + ff, 1) && check2(i)) {
        res += 'a' + lc;
        if (check(i + 1)) {
          cout << res;
          return 0;
        }
      }
    }
    res.clear();
    for (int j = 0; j < i; j++) res += s[j];
    if (lv != 100) {
      fill(ans, ans + N, -1);
      if (setc(i * 2 + ss, 1) && check2(i)) {
        res += 'a' + lv;
        if (check(i + 1)) {
          cout << res;
          return 0;
        }
      }
    }
  }
  cout << -1;
  cin >> n;
}
