#include <bits/stdc++.h>
using namespace std;
const int A = 26;
const int N = 205;
int n, m, l;
char buf[N];
bool alpha[A];
vector<int> go[2 * N];
vector<int> go_back[2 * N];
char s[N];
int nxt[A][2];
bool used[2 * N];
int topo[2 * N];
int topos;
int cur_comp;
int comp[2 * N];
void dfs_topo(int v) {
  used[v] = true;
  for (int to : go[v])
    if (!used[to]) dfs_topo(to);
  topo[topos++] = v;
}
void dfs_scc(int v) {
  comp[v] = cur_comp;
  for (int to : go_back[v])
    if (comp[to] == -1) dfs_scc(to);
}
bool is_good(int strict_until) {
  for (int i = 0; i < n; i++)
    if (i <= strict_until || (i > strict_until && nxt[0][1] == -1)) {
      int col = alpha[s[i] - 'a'];
      go[2 * i + (1 - col)].push_back(2 * i + col);
      go_back[2 * i + col].push_back(2 * i + (1 - col));
    }
  fill(used, used + 2 * n, false);
  topos = 0;
  for (int i = 0; i < 2 * n; i++)
    if (!used[i]) dfs_topo(i);
  reverse(topo, topo + topos);
  fill(comp, comp + 2 * n, -1);
  cur_comp = 0;
  for (int i = 0; i < 2 * n; i++) {
    int v = topo[i];
    if (comp[v] == -1) {
      dfs_scc(v);
      cur_comp++;
    }
  }
  for (int i = 0; i <= strict_until; i++)
    if (i <= strict_until || (i > strict_until && nxt[0][1] == -1)) {
      int col = alpha[s[i] - 'a'];
      go[2 * i + (1 - col)].pop_back();
      go_back[2 * i + col].pop_back();
    }
  for (int i = 0; i < n; i++)
    if (comp[2 * i] == comp[2 * i + 1]) return false;
  return true;
}
void dump() {
  puts(s);
  exit(0);
}
void now_forward(int strict_until) {
  for (int i = strict_until + 1; i < n; i++) {
    int a = 0;
    int b = nxt[0][1];
    s[i] = 'a' + a;
    if (is_good(i)) continue;
    if (b != -1) {
      s[i] = 'a' + b;
      if (is_good(i)) continue;
    }
    throw;
  }
  dump();
}
void read() {
  scanf("%s", buf);
  l = strlen(buf);
  for (int i = 0; i < l; i++) alpha[i] = (buf[i] == 'V');
  scanf("%d%d", &n, &m);
  for (int i = 0; i < m; i++) {
    int a, c;
    char _b[2], _d[2];
    scanf("%d%s%d%s", &a, _b, &c, _d);
    a--;
    c--;
    int b = (_b[0] == 'V');
    int d = (_d[0] == 'V');
    go[2 * a + b].push_back(2 * c + d);
    go_back[2 * c + d].push_back(2 * a + b);
    go[2 * c + (1 - d)].push_back(2 * a + (1 - b));
    go_back[2 * a + (1 - b)].push_back(2 * c + (1 - d));
  }
  scanf("%s", s);
}
void solve() {
  read();
  for (int i = 0; i < l; i++) {
    nxt[i][0] = nxt[i][1] = -1;
    for (int j = i + 1; j < l; j++) {
      if (nxt[i][0] == -1 && alpha[i] == alpha[j]) nxt[i][0] = j;
      if (nxt[i][1] == -1 && alpha[i] != alpha[j]) nxt[i][1] = j;
    }
  }
  if (is_good(n - 1)) now_forward(n - 1);
  for (int i = n - 1; i >= 0; i--) {
    int a = nxt[s[i] - 'a'][0];
    int b = nxt[s[i] - 'a'][1];
    if (a > b) swap(a, b);
    if (a != -1) {
      s[i] = 'a' + a;
      if (is_good(i)) now_forward(i);
    }
    if (b != -1) {
      s[i] = 'a' + b;
      if (is_good(i)) now_forward(i);
    }
  }
  puts("-1");
}
int main() {
  solve();
  0;
  return 0;
}
