#include <bits/stdc++.h>
int dx[4] = {0, -1, 0, 1};
int dy[4] = {1, 0, -1, 0};
using namespace std;
string letter, s;
int n, m;
vector<int> ori[456];
inline int get(char c) { return c == 'V' ? 0 : 1; }
vector<int> node[456];
int dep[456], low[456], wh[456], st[456];
int top, scnt;
bool ins[456];
void dfs(int u, int d = 0) {
  st[top++] = u;
  low[u] = dep[u] = d;
  ins[u] = true;
  for (int v : node[u]) {
    if (dep[v] != -1) {
      if (ins[v]) low[u] = min(low[u], low[v]);
    } else {
      dfs(v, d + 1);
      low[u] = min(low[u], low[v]);
    }
  }
  if (low[u] == dep[u]) {
    wh[u] = scnt;
    while (st[top - 1] != u) {
      int v = st[top-- - 1];
      wh[v] = scnt;
      ins[v] = false;
    }
    top--;
    ins[u] = false;
    scnt++;
  }
}
bool ok(string s) {
  for (int i = 0; i < int(n * 2); ++i) node[i].clear();
  for (int u = 0; u < int(n * 2); ++u)
    for (int v : ori[u]) node[u].push_back(v);
  for (int i = 0; i < int(n); ++i)
    if (s[i] != 0) {
      int c = get(letter[s[i] - 'a']);
      node[i * 2 + 1 - c].push_back(i * 2 + c);
    }
  memset(dep, -1, sizeof dep);
  memset(low, -1, sizeof low);
  memset(ins, false, sizeof ins);
  top = 0;
  scnt = 0;
  for (int i = 0; i < int(n * 2); ++i)
    if (dep[i] == -1) dfs(i);
  for (int i = 0; i < int(n); ++i)
    if (wh[i * 2] == wh[i * 2 + 1]) return false;
  return true;
}
string work(int id, bool zero = false, string str = s) {
  if (id == n) return ok(str) ? str : "";
  int v = -1, c = -1;
  int start = zero ? 0 : str[id] - 'a' + 1;
  for (int i = start; i < letter.length(); i++) {
    if (get(letter[i]) == 0 && v == -1) v = i;
    if (get(letter[i]) == 1 && c == -1) c = i;
  }
  string tmp = str;
  for (int i = id + 1; i < n; i++) tmp[i] = 0;
  if (v > c) swap(v, c);
  string ret;
  if (v != -1) {
    tmp[id] = 'a' + v;
    if (ok(tmp)) {
      ret = work(id + 1, true, tmp);
      if (ret.length()) return ret;
    }
  }
  if (c != -1) {
    tmp[id] = 'a' + c;
    if (ok(tmp)) {
      ret = work(id + 1, true, tmp);
      if (ret.length()) return ret;
    }
  }
  return "";
}
int Main() {
  ios_base::sync_with_stdio(0);
  cin >> letter;
  cin >> n >> m;
  for (int i = 0; i < int(m); ++i) {
    int u1, u2;
    char c1, c2;
    cin >> u1 >> c1 >> u2 >> c2;
    u1--;
    u2--;
    ori[u1 * 2 + get(c1)].push_back(u2 * 2 + get(c2));
    ori[u2 * 2 + 1 - get(c2)].push_back(u1 * 2 + 1 - get(c1));
  }
  cin >> s;
  if (ok(s)) {
    cout << s << endl;
    return 0;
  }
  for (int i = n - 1; i >= 0; i--) {
    string ans = work(i);
    if (ans.size()) {
      cout << ans << endl;
      return 0;
    }
  }
  puts("-1");
  return 0;
}
int main() { return Main(); }
