#include <bits/stdc++.h>
using namespace std;
const int N = 400 + 5;
int adj[N][N];
void addEdge(int p1, char t1, int p2, char t2, int n) {
  int a = p1;
  if (t1 == 'V') a += n;
  int b = p2;
  if (t2 == 'V') b += n;
  adj[a][b] = 1;
}
bool isOk(string &s, int t, int n, string &vc) {
  for (int i = 1; i <= t; i++) {
    int a = i;
    if (vc[s[i - 1] - 'a'] == 'V') a += n;
    for (int j = 1; j <= t; j++) {
      if (adj[a][j] and vc[s[j - 1] - 'a'] != 'C') return 0;
      if (adj[a][j + n] and vc[s[j - 1] - 'a'] != 'V') return 0;
    }
  }
  return 1;
}
int try_fill(int p, int q, int n, string &s, string &vc, int l) {
  if (p > n) return 1;
  int t = 0;
  if (q == 0) t = s[p - 1] - 'a' + 1;
  int v = 0, c = 0;
  for (int i = t; i < l; i++) {
    if (vc[i] == 'C') {
      if (c) continue;
      c = 1;
      char temp = 'a' + i;
      swap(s[p - 1], temp);
      int ok = 1;
      for (int j = 1; j <= p; j++) {
        if ((adj[p][j] and vc[s[j - 1] - 'a'] != 'C') or
            (adj[p][j + n] and vc[s[j - 1] - 'a'] != 'V')) {
          ok = 0;
          break;
        }
      }
      if (ok) {
        return try_fill(p + 1, 1, n, s, vc, l);
      } else {
        swap(s[p - 1], temp);
      }
    } else {
      if (v) continue;
      v = 1;
      char temp = 'a' + i;
      swap(s[p - 1], temp);
      int ok = 1;
      for (int j = 1; j <= p; j++) {
        if ((adj[p + n][j] and vc[s[j - 1] - 'a'] != 'C') or
            (adj[p + n][j + n] and vc[s[j - 1] - 'a'] != 'V')) {
          ok = 0;
          break;
        }
      }
      if (ok) {
        return try_fill(p + 1, 1, n, s, vc, l);
      } else {
        swap(s[p - 1], temp);
      }
    }
  }
  return 0;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  string vc;
  cin >> vc;
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= m; i++) {
    int p1, p2;
    char t1, t2;
    cin >> p1 >> t1 >> p2 >> t2;
    addEdge(p1, t1, p2, t2, n);
    if (t1 == 'V')
      t1 = 'C';
    else
      t1 = 'V';
    if (t2 == 'V')
      t2 = 'C';
    else
      t2 = 'V';
    addEdge(p2, t2, p1, t1, n);
  }
  string s;
  cin >> s;
  for (int i = 1; i <= 2 * n; i++) {
    adj[i][i] = 1;
  }
  for (int k = 1; k <= 2 * n; k++) {
    for (int i = 1; i <= 2 * n; i++) {
      for (int j = 1; j <= 2 * n; j++) {
        if (adj[i][k] and adj[k][j]) adj[i][j] = 1;
      }
    }
  }
  int nc = 0;
  for (char t : vc) {
    if (t == 'C') nc++;
  }
  if (nc == (int)vc.length()) {
    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= n; j++) {
        if (adj[i][j + n]) {
          cout << "-1\n";
          exit(0);
        }
      }
    }
  }
  if (nc == 0) {
    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= n; j++) {
        if (adj[i + n][j]) {
          cout << "-1\n";
          exit(0);
        }
      }
    }
  }
  int p;
  for (int i = n; i >= 0; i--) {
    if (isOk(s, i, n, vc)) {
      p = i;
      break;
    }
  }
  for (int i = p; i >= 0; i--) {
    if (try_fill(i + 1, 0, n, s, vc, vc.length())) {
      cout << s << "\n";
      exit(0);
    }
  }
  cout << "-1\n";
  return 0;
}
