#include <bits/stdc++.h>
using namespace std;
const int SIZE = 400;
int N, M;
string config, input, result;
vector<int> adj[SIZE];
int nott(int x) { return x >= N ? x - N : x + N; }
int nextId, groupId, id[SIZE], lowLink[SIZE], group[SIZE];
vector<int> st;
bool inStack[SIZE];
void dfs(int n) {
  id[n] = lowLink[n] = nextId++;
  st.push_back(n);
  inStack[n] = true;
  for (int i = 0; i < adj[n].size(); i++) {
    if (id[adj[n][i]] == -1) {
      dfs(adj[n][i]);
      lowLink[n] = min(lowLink[n], lowLink[adj[n][i]]);
    } else if (inStack[adj[n][i]]) {
      lowLink[n] = min(lowLink[n], lowLink[adj[n][i]]);
    }
  }
  if (id[n] == lowLink[n]) {
    while (true) {
      int x = st.back();
      st.pop_back();
      group[x] = groupId;
      inStack[x] = false;
      if (x == n) break;
    }
    groupId++;
  }
}
bool validate() {
  nextId = groupId = 0;
  memset(id, -1, sizeof id);
  memset(inStack, 0, sizeof inStack);
  for (int i = 0; i < 2 * N; i++) {
    if (id[i] == -1) dfs(i);
  }
  for (int i = 0; i < N; i++)
    if (group[i] == group[(nott(i))]) return false;
  return true;
}
int table[201][2];
bool go(int idx, bool eq) {
  if (idx >= N) return true;
  if (table[idx][eq] != -1) return table[idx][eq];
  int start = eq ? input[idx] - 'a' : 0;
  bool checkedV = false, checkedC = false;
  for (; start < config.size(); start++) {
    if (start > input[idx] - 'a') {
      if (config[start] == 'V') {
        if (checkedV) continue;
        checkedV = true;
      }
      if (config[start] == 'C') {
        if (checkedC) continue;
        checkedC = true;
      }
    }
    result[idx] = 'a' + start;
    int a = config[start] == 'V' ? idx : nott(idx);
    adj[nott(a)].push_back(a);
    bool v = validate();
    if (v && go(idx + 1, (eq && start == input[idx] - 'a'))) {
      return table[idx][eq] = true;
    }
    adj[nott(a)].pop_back();
  }
  return table[idx][eq] = false;
}
int main() {
  cin >> config >> N >> M;
  for (int i = 0; i < M; i++) {
    int p1, p2;
    char t1, t2;
    cin >> p1 >> t1 >> p2 >> t2;
    p1--;
    p2--;
    int a = t1 == 'V' ? nott(p1) : p1;
    int b = t2 == 'V' ? p2 : nott(p2);
    adj[nott(a)].push_back(b);
    adj[nott(b)].push_back(a);
  }
  cin >> input;
  result = input;
  memset(table, -1, sizeof table);
  cout << (go(0, true) ? result : "-1") << endl;
  return 0;
}
