#include <bits/stdc++.h>
using namespace std;
const int N = 510, M = 1e6 + 100;
int n, m, dfn[N], low[N], in[N], color[N], w, cnt, fa[N];
int ans[N], vi[N], pass[N][N];
int tot, first[N], nxt[M], point[M];
char ch[N];
stack<int> s;
vector<int> p[2], e[N];
string last;
map<pair<int, int>, int> mp;
struct node {
  int x, a, y, b;
} t[M];
inline int read() {
  int f = 1, x = 0;
  char s = getchar();
  while (s < '0' || s > '9') {
    if (s == '-') f = -1;
    s = getchar();
  }
  while (s >= '0' && s <= '9') {
    x = x * 10 + s - '0';
    s = getchar();
  }
  return x * f;
}
inline void add_edge(int x, int y) {
  nxt[++tot] = first[x];
  first[x] = tot;
  point[tot] = y;
}
inline int get(int x, int tp) {
  int ans = 0x3f3f3f3f;
  for (int i = 0; i < (int)p[tp].size(); i++)
    if (p[tp][i] >= ch[x] - 'a') ans = min(ans, p[tp][i]);
  return ans;
}
inline int getpos(int x, int tp) {
  int ans = 0x3f3f3f3f;
  for (int i = 0; i < (int)p[tp].size(); i++)
    if (p[tp][i] > ch[x] - 'a') ans = min(ans, p[tp][i]);
  return ans;
}
inline int top(int tp) {
  if (p[tp].empty()) return 0x3f3f3f3f;
  return p[tp][0];
}
void dfs(int x) {
  s.push(x);
  dfn[x] = low[x] = ++cnt;
  in[x] = 1;
  for (int i = first[x]; i != -1; i = nxt[i]) {
    int u = point[i];
    if (!dfn[u])
      dfs(u), low[x] = min(low[x], low[u]);
    else if (in[u])
      low[x] = min(low[x], dfn[u]);
  }
  if (dfn[x] == low[x]) {
    w++;
    while (s.top() != x) color[s.top()] = w, in[s.top()] = 0, s.pop();
    color[x] = w, in[x] = 0;
    s.pop();
  }
}
void dfs1(int x, int pos) {
  int id = (x > n) ? x - n : x;
  vi[id] = 1;
  if (id == pos)
    ans[id] = getpos(pos, x > n);
  else if (id > pos)
    ans[id] = top(x > n);
  else
    ans[id] = get(id, x > n);
  for (int i = first[x]; i != -1; i = nxt[i]) {
    int u = point[i];
    if (vi[(u > n) ? u - n : u]) continue;
    dfs1(u, pos);
  }
}
void dfs2(int x, int s) {
  pass[s][x] = 1;
  for (int i = 0; i < (int)e[x].size(); i++)
    if (!vi[e[x][i]]) dfs2(e[x][i], s);
}
bool solve(int pos) {
  tot = -1;
  memset(first, -1, sizeof(first));
  for (int i = 1; i <= m; i++) {
    add_edge(t[i].x + t[i].a * n, t[i].y + t[i].b * n);
    add_edge(t[i].y + (t[i].b ^ 1) * n, t[i].x + (t[i].a ^ 1) * n);
  }
  for (int i = 1; i < pos; i++) {
    if (get(i, 0) != ch[i] - 'a') add_edge(i, i + n);
    if (get(i, 1) != ch[i] - 'a') add_edge(i + n, i);
  }
  if (pos) {
    if (getpos(pos, 0) == 0x3f3f3f3f) add_edge(pos, pos + n);
    if (getpos(pos, 1) == 0x3f3f3f3f) add_edge(pos + n, pos);
  }
  memset(dfn, 0, sizeof(dfn));
  cnt = w = 0;
  while (!s.empty()) s.pop();
  for (int i = 1; i <= 2 * n; i++) {
    if (dfn[i]) continue;
    dfs(i);
  }
  bool bl = 1;
  for (int i = 1; i <= n; i++)
    if (color[i] == color[i + n]) bl = 0;
  if (!bl) return 0;
  return 1;
}
bool tr(int pos) {
  mp.clear();
  for (int i = 1; i <= w; i++)
    e[i].clear(), memset(pass[i], 0, (w + 10) * sizeof(int));
  for (int i = 1; i <= 2 * n; i++) {
    for (int j = first[i]; j != -1; j = nxt[j]) {
      int u = point[j];
      if (color[u] == color[i]) continue;
      if (mp[make_pair(color[i], color[u])]) continue;
      mp[make_pair(color[i], color[u])] = 1;
      e[color[i]].push_back(color[u]);
    }
  }
  for (int i = 1; i <= w; i++) dfs2(i, i);
  memset(vi, 0, sizeof(vi));
  for (int i = 1; i <= n; i++) {
    if (vi[i]) continue;
    ans[i] = 0x3f3f3f3f;
    int now = 0, wh;
    if (pass[color[i]][color[i + n]] || pass[color[i + n]][color[i]])
      now = (color[i + n] < color[i]);
    ans[i] =
        ((i <= pos) ? (i == pos ? getpos(i, now) : get(i, now)) : top(now));
    wh = now;
    if (!pass[color[i]][color[i + n]] && !pass[color[i + n]][color[i]]) {
      now ^= 1;
      int val =
          ((i <= pos) ? (i == pos ? getpos(i, now) : get(i, now)) : top(now));
      if (val < ans[i]) wh = now;
      ans[i] = min(ans[i], val);
    }
    if (i == pos) ans[i] = ch[i] - 'a' + 1;
    dfs1(i + wh * n, pos);
  }
  for (int i = 1; i <= n; i++)
    if (ans[i] == 0x3f3f3f3f) return 0;
  return 1;
}
signed main() {
  tot = -1;
  memset(first, -1, sizeof(first));
  scanf("%s", ch);
  int len = strlen(ch);
  for (int i = 0; i < len; i++) p[ch[i] == 'V'].push_back(i);
  n = read();
  m = read();
  for (int i = 1; i <= m; i++) {
    int x, y, a, b;
    char t1[5], t2[5];
    scanf("%d%s%d%s", &x, t1, &y, t2);
    a = (t1[0] == 'V');
    b = (t2[0] == 'V');
    t[i] = (node){x, a, y, b};
  }
  scanf("%s", ch + 1);
  for (int i = 1; i <= n; i++) last.push_back(255);
  bool bl = 1;
  for (int i = n + 1; i >= 1; i--) {
    if (!solve(i)) continue;
    if (!tr(i)) continue;
    string now;
    bl = 0;
    for (int i = 1; i <= n; i++) now.push_back('a' + ans[i]);
    if (now < last) last = now;
  }
  if (bl)
    printf("-1\n");
  else
    cout << last << endl;
}
