#include <bits/stdc++.h>
using namespace std;
struct _ {
  ios_base::Init i;
  _() {
    cin.sync_with_stdio(0);
    cin.tie(0);
  }
} _;
struct SAT2 {
  int n, group_label;
  vector<int> edge[500], reverse_edge[500];
  vector<int> traversed_order;
  int group_number[500];
  int vis[500];
  SAT2() {}
  SAT2(int n) : n(n) {}
  void add_edge(int first, int second) {
    edge[first].push_back(second);
    reverse_edge[second].push_back(first);
  }
  void pop_edge(int first) {
    int second = edge[first].back();
    edge[first].pop_back();
    reverse_edge[second].pop_back();
  }
  void dfs1(int u) {
    vis[u] = 1;
    for (auto& v : edge[u]) {
      if (vis[v] != 1) {
        dfs1(v);
      }
    }
    traversed_order.push_back(u);
  }
  void dfs2(int u) {
    group_number[u] = group_label;
    vis[u] = 2;
    for (auto& v : reverse_edge[u]) {
      if (vis[v] != 2) {
        dfs2(v);
      }
    }
  }
  bool is_sat() {
    memset(vis, 0, sizeof(vis));
    traversed_order.clear();
    for (int i = (0); i < (n); ++i) {
      if (vis[i] != 1) {
        dfs1(i);
      }
    }
    group_label = 0;
    memset(vis, 0, sizeof(vis));
    for (int i = (n - 1); i >= (0); --i) {
      if (vis[traversed_order[i]] != 2) {
        dfs2(traversed_order[i]);
        group_label++;
      }
    }
    for (int i = (0); i < (n / 2); ++i) {
      if (group_number[i * 2] == group_number[i * 2 + 1]) {
        return false;
      }
    }
    return true;
  }
};
bool is_vowel[30];
string s;
int N, M;
SAT2 sat;
bool prefix_choice_satisfiable(int prefix_length) {
  for (int i = (0); i < (prefix_length); ++i) {
    sat.add_edge(2 * i + (!is_vowel[s[i] - 'a']), 2 * i + is_vowel[s[i] - 'a']);
  }
  bool is_sat = sat.is_sat();
  for (int i = (0); i < (prefix_length); ++i) {
    sat.pop_edge(2 * i + !is_vowel[s[i] - 'a']);
  }
  return is_sat;
}
int main(int argc, char** argv) {
  string alpha;
  cin >> alpha;
  int L = alpha.length();
  for (int i = (0); i < (L); ++i) {
    is_vowel[i] = (alpha[i] == 'V');
  }
  int min_vowel = -1;
  int min_consonent = -1;
  for (int i = (0); i < (L); ++i)
    if (is_vowel[i]) {
      min_vowel = i;
      break;
    }
  for (int i = (0); i < (L); ++i)
    if (!is_vowel[i]) {
      min_consonent = i;
      break;
    }
  cin >> N >> M;
  sat = SAT2(N + N);
  for (int i = (0); i < (M); ++i) {
    string t1, t2;
    int p1, p2;
    cin >> p1 >> t1 >> p2 >> t2;
    --p1, --p2;
    sat.add_edge(p1 * 2 + (t1 == "V"), p2 * 2 + (t2 == "V"));
    sat.add_edge(p2 * 2 + (t2 != "V"), p1 * 2 + (t1 != "V"));
  }
  cin >> s;
  if (prefix_choice_satisfiable(N)) {
    cout << s;
  } else {
    for (int i = (N - 1); i >= (0); --i) {
      bool tried[2] = {false, false};
      for (int j = (s[i] - 'a' + 1); j < (L); ++j) {
        if (tried[is_vowel[j]]) continue;
        tried[is_vowel[j]] = true;
        s[i] = 'a' + j;
        if (!prefix_choice_satisfiable(i + 1)) continue;
        for (int k = (i + 1); k < (N); ++k) {
          int trial[2] = {min_vowel, min_consonent};
          sort(trial, trial + 2);
          for (int z = (0); z < (2); ++z) {
            if (trial[z] == -1) continue;
            s[k] = 'a' + trial[z];
            if (prefix_choice_satisfiable(k + 1)) break;
          }
        }
        if (prefix_choice_satisfiable(N)) {
          cout << s;
          return 0;
        }
      }
    }
    cout << "-1";
  }
  return 0;
}
