#include <bits/stdc++.h>
using namespace std;
int n, m, q;
bool vowel[404];
char s[404];
bool need[404][404];
int curState[404];
bool canVowel[404], canConso[404];
void init(void) {
  scanf("%s", s);
  q = strlen(s);
  for (int i = 0, _n = (q); i < _n; i = i + 1) vowel[i] = s[i] == 'V';
  scanf("%d%d", &n, &m);
  for (int love = 0, _n = (m); love < _n; love = love + 1) {
    char u[2], v[2];
    int x, y;
    scanf("%d%s%d%s", &x, u, &y, v);
    int a = u[0] == 'V' ? (x) : ((x) + n);
    int b = v[0] == 'V' ? (y) : ((y) + n);
    need[a][b] = true;
    need[((b) > n ? (b)-n : (b) + n)][((a) > n ? (a)-n : (a) + n)] = true;
  }
  scanf("%s", s + 1);
  s[0] = 0;
}
void warshall(void) {
  for (int i = (1), _b = (2 * n); i <= _b; i = i + 1) need[i][i] = true;
  for (int k = (1), _b = (2 * n); k <= _b; k = k + 1)
    for (int i = (1), _b = (2 * n); i <= _b; i = i + 1)
      for (int j = (1), _b = (2 * n); j <= _b; j = j + 1)
        if (need[i][k] && need[k][j]) need[i][j] = true;
  for (int i = (1), _b = (n); i <= _b; i = i + 1) {
    canVowel[i] = canConso[i] = true;
    if (need[(i)][((i) + n)]) canVowel[i] = false;
    if (need[((i) + n)][(i)]) canConso[i] = false;
    for (int j = (1), _b = (n); j <= _b; j = j + 1)
      if (i != j && need[(i)][(j)] && need[(i)][((j) + n)]) canVowel[i] = false;
    for (int j = (1), _b = (n); j <= _b; j = j + 1)
      if (i != j && need[((i) + n)][(j)] && need[((i) + n)][((j) + n)])
        canConso[i] = false;
  }
}
bool checkVowel(int pos) {
  if (curState[pos] == 0) return (false);
  if (!canVowel[pos]) return (false);
  for (int i = (1), _b = (n); i <= _b; i = i + 1)
    if (i != pos) {
      if (need[(pos)][(i)] && curState[i] == 0) return (false);
      if (need[(pos)][((i) + n)] && curState[i] == 1) return (false);
    }
  return (true);
}
bool checkConso(int pos) {
  if (curState[pos] == 1) return (false);
  if (!canConso[pos]) return (false);
  for (int i = (1), _b = (n); i <= _b; i = i + 1)
    if (i != pos) {
      if (need[((pos) + n)][(i)] && curState[i] == 0) return (false);
      if (need[((pos) + n)][((i) + n)] && curState[i] == 1) return (false);
    }
  return (true);
}
void fixVowel(int pos) {
  curState[pos] = 1;
  for (int i = (1), _b = (n); i <= _b; i = i + 1)
    if (i != pos) {
      if (need[(pos)][(i)]) curState[i] = 1;
      if (need[(pos)][((i) + n)]) curState[i] = 0;
    }
}
void fixConso(int pos) {
  curState[pos] = 0;
  for (int i = (1), _b = (n); i <= _b; i = i + 1)
    if (i != pos) {
      if (need[((pos) + n)][(i)]) curState[i] = 1;
      if (need[((pos) + n)][((i) + n)]) curState[i] = 0;
    }
}
string checkPrefix(int len) {
  memset(curState, -1, sizeof curState);
  for (int i = (1), _b = (len); i <= _b; i = i + 1) {
    if (vowel[s[i] - 'a']) {
      if (!checkVowel(i)) return ("");
      fixVowel(i);
    } else {
      if (!checkConso(i)) return ("");
      fixConso(i);
    }
  }
  string res;
  for (int i = (1), _b = (len); i <= _b; i = i + 1) res.push_back(s[i]);
  for (int i = (len + 1), _b = (n); i <= _b; i = i + 1) {
    char minV = -1;
    char minC = -1;
    for (int j = (i == len + 1 ? s[i] + 1 : 'a'), _b = ('a' + q - 1); j <= _b;
         j = j + 1) {
      if (vowel[j - 'a']) {
        if (minV < 0) minV = j;
      } else {
        if (minC < 0) minC = j;
      }
    }
    set<char> can;
    if (minV >= 0) can.insert(minV);
    if (minC >= 0) can.insert(minC);
    bool ok = false;
    for (__typeof((can).begin()) it = (can).begin(); it != (can).end(); it++) {
      bool canPut = vowel[*it - 'a'] ? checkVowel(i) : checkConso(i);
      if (canPut) {
        if (vowel[*it - 'a'])
          fixVowel(i);
        else
          fixConso(i);
        res.push_back(*it);
        ok = true;
        break;
      }
    }
    if (!ok) return ("");
  }
  return (res);
}
void process(void) {
  for (int i = (n), _a = (0); i >= _a; i = i - 1) {
    string tmp = checkPrefix(i);
    if (!tmp.empty()) {
      cout << tmp << endl;
      return;
    }
  }
  cout << -1 << endl;
}
int main(void) {
  init();
  warshall();
  process();
  return 0;
}
