#include <bits/stdc++.h>
using namespace std;
const int inf = (int)1.01e9;
const double eps = 1e-9;
const int maxn = (int)1010 + 10;
char s[maxn];
int t[maxn];
vector<pair<int, pair<int, int> > > v[maxn];
int mark[maxn];
int col[maxn];
bool ok;
int n;
int mx[2];
void dfs(int x, int c, int okret = 1) {
  if (col[x] != -1 && col[x] != c) {
    ok = false;
  }
  if (okret && !ok) return;
  if (mark[x]) return;
  mark[x] = 1;
  col[x] = c;
  for (int i = 0; (i) < (((int)(v[x]).size())); ++i) {
    int t1 = v[x][i].first;
    int y = v[x][i].second.first;
    int t2 = v[x][i].second.second;
    if (t1 == c) dfs(y, t2, okret);
  }
}
bool checkNeed(int x, int t1, int y, int t2) {
  ok = true;
  for (int i = 0; (i) < (n); ++i) mark[i] = 0, col[i] = -1;
  dfs(x, t1, 0);
  if (col[y] != t2) return true;
  return false;
}
int L;
bool allOk(int l, int gr) {
  for (int i = 0; (i) < (n); ++i) mark[i] = 0, col[i] = -1;
  for (int i = 0; (i) < (l); ++i) col[i] = t[s[i] - 'a'];
  ok = true;
  for (int i = 0; (i) < (l); ++i)
    if (mark[i] == 0) dfs(i, col[i]);
  if (ok && gr == 0) {
    for (int i = l; i < n; ++i) {
      int have = s[i] - 'a';
      int need = L - 1;
      if (col[i] != -1) need = mx[col[i]];
      if (have < need) return true;
      if (have > need) return false;
    }
  }
  return ok;
}
const int maxe = 4 * maxn * maxn;
pair<pair<int, int>, pair<int, int> > E[maxe];
int sv[maxn];
int main() {
  scanf("%s", s);
  L = strlen(s);
  for (int i = 0; (i) < (L); ++i)
    if (s[i] == 'V') t[i] = 1;
  for (int i = 0; (i) < (2); ++i) mx[i] = -1;
  for (int i = 0; (i) < (L); ++i) mx[t[i]] = i;
  int m;
  scanf("%d%d", &n, &m);
  for (int i = 0; (i) < (m); ++i) {
    int x, y;
    char c[2], d[2];
    scanf("%d%s%d%s", &x, c, &y, d);
    --x, --y;
    int t1 = 0, t2 = 0;
    if (c[0] == 'V') t1 = 1;
    if (d[0] == 'V') t2 = 1;
    if (x > y) {
      swap(x, y);
      swap(t1, t2);
      t1 = 1 - t1;
      t2 = 1 - t2;
    }
    E[i] = make_pair(make_pair(x, y), make_pair(t1, t2));
  }
  sort(E, E + m);
  for (int i = 0; (i) < (m); ++i) {
    int x = E[i].first.first;
    int y = E[i].first.second;
    int t1 = E[i].second.first;
    int t2 = E[i].second.second;
    {
      v[x].push_back(make_pair(t1, make_pair(y, t2)));
      v[y].push_back(make_pair(1 - t2, make_pair(x, 1 - t1)));
    }
  }
  for (int i = 0; (i) < (n); ++i) sv[i] = -1;
  scanf("%s", s);
  int gr = 0;
  for (int i = 0; (i) < (n); ++i) {
    int start = s[i];
    if (gr) start = 'a';
    int end = 'a' + L - 1;
    bool fail = true;
    for (int c = start; c <= end; ++c) {
      if (sv[i] != -1 && t[c - 'a'] != sv[i]) {
        gr = 1;
        continue;
      }
      s[i] = c;
      if (allOk(i + 1, gr)) {
        fail = false;
        for (int j = 0; (j) < (n); ++j) sv[j] = col[j];
        break;
      }
      gr = 1;
    }
    if (fail) {
      printf("-1\n");
      return 0;
    }
  }
  printf("%s\n", s);
  return 0;
}
