#include <bits/stdc++.h>
using namespace std;
const char CONSONANT_CHAR = 'C';
const char VOCAL_CHAR = 'V';
char buf[205];
string alphabet;
int alphabetLetterType[50];
int nextTypeInAlphabet[50][2];
int alphabetSize;
vector<pair<int, int>> g[205][2];
int m;
string sChars;
int s[205];
int n;
vector<pair<int, int>> obligatoryTypes;
bool isObligatory[205][2];
bool f[2][205][2];
pair<int, int> q[405];
int ansObligatoryType[205];
int curObligatory[205];
int ans[205], curAns[205];
bool haveAns;
int qInt[205];
void NO() {
  printf("-1\n");
  exit(0);
}
int typeToInt(char c) {
  if (c == CONSONANT_CHAR)
    return 0;
  else
    return 1;
}
void buildNextLetterType() {
  for (int i = 0; i < alphabetSize; i++)
    alphabetLetterType[i] = typeToInt(alphabet[i]);
  nextTypeInAlphabet[alphabetSize][0] = nextTypeInAlphabet[alphabetSize][1] =
      -1;
  for (int i = alphabetSize - 1; i >= 0; i--) {
    for (int j = 0; j < 2; j++)
      nextTypeInAlphabet[i][j] = nextTypeInAlphabet[i + 1][j];
    nextTypeInAlphabet[i][alphabetLetterType[i]] = i;
  }
}
void addRule(int pos1, int t1, int pos2, int t2) {
  g[pos1][t1].push_back(make_pair(pos2, t2));
}
void walkGraph(int sPos, int sType, bool f[205][2]) {
  for (int i = 0; i < n; i++)
    for (int j = 0; j < 2; j++) f[i][j] = false;
  f[sPos][sType] = true;
  q[0] = make_pair(sPos, sType);
  int qSize = 1;
  for (int i = 0; i < qSize; i++) {
    int pos = q[i].first, type = q[i].second;
    for (int j = 0; j < (int)g[pos][type].size(); j++) {
      int nextPos = g[pos][type][j].first;
      int nextType = g[pos][type][j].second;
      if (!f[nextPos][nextType]) {
        f[nextPos][nextType] = true;
        q[qSize] = make_pair(nextPos, nextType);
        qSize++;
      }
    }
  }
}
void findObligatoryTypes(int pos) {
  for (int i = 0; i < 2; i++) walkGraph(pos, i, f[i]);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 2; j++) {
      if (f[0][i][j] && f[1][i][j]) {
        obligatoryTypes.push_back(make_pair(i, j));
        isObligatory[i][j] = true;
      }
    }
  }
}
void addObligatory(int sPos, int sType) {
  curObligatory[sPos] = sType;
  qInt[0] = sPos;
  int qSize = 1;
  for (int i = 0; i < qSize; i++) {
    int pos = qInt[i];
    int type = curObligatory[pos];
    for (int j = 0; j < (int)g[pos][type].size(); j++) {
      int nextPos = g[pos][type][j].first;
      int nextType = g[pos][type][j].second;
      if (curObligatory[nextPos] == -1) {
        curObligatory[nextPos] = nextType;
        qInt[qSize] = nextPos;
        qSize++;
      }
    }
  }
}
void tryAnswer(int firstDifferPos) {
  for (int i = 0; i < n; i++) curObligatory[i] = ansObligatoryType[i];
  for (int i = 0; i < firstDifferPos; i++) {
    if (curObligatory[i] != -1 && curObligatory[i] != alphabetLetterType[s[i]])
      return;
    if (curObligatory[i] == -1) addObligatory(i, alphabetLetterType[s[i]]);
    curAns[i] = s[i];
  }
  if (firstDifferPos == n) {
    haveAns = true;
    for (int i = 0; i < n; i++) ans[i] = curAns[i];
    return;
  }
  if (s[firstDifferPos] == alphabetSize - 1) return;
  int differLetter = s[firstDifferPos] + 1;
  if (curObligatory[firstDifferPos] == -1 ||
      curObligatory[firstDifferPos] == alphabetLetterType[differLetter]) {
    if (curObligatory[firstDifferPos] == -1)
      addObligatory(firstDifferPos, alphabetLetterType[differLetter]);
    curAns[firstDifferPos] = differLetter;
  } else {
    int nextLetter =
        nextTypeInAlphabet[differLetter][alphabetLetterType[differLetter] ^ 1];
    if (nextLetter == -1) return;
    if (curObligatory[firstDifferPos] == -1)
      addObligatory(firstDifferPos, alphabetLetterType[nextLetter]);
    curAns[firstDifferPos] = nextLetter;
  }
  for (int i = firstDifferPos + 1; i < n; i++) {
    if (curObligatory[i] != -1 && nextTypeInAlphabet[0][curObligatory[i]] == -1)
      return;
    int nextLetter;
    if (curObligatory[i] == -1) {
      nextLetter = 0;
      addObligatory(i, alphabetLetterType[nextLetter]);
    } else {
      nextLetter = nextTypeInAlphabet[0][curObligatory[i]];
    }
    curAns[i] = nextLetter;
  }
  haveAns = true;
  for (int i = 0; i < n; i++) ans[i] = curAns[i];
}
int main() {
  scanf("%s", buf);
  alphabet = string(buf);
  alphabetSize = (int)alphabet.size();
  buildNextLetterType();
  scanf("%d%d", &n, &m);
  for (int i = 0; i < m; i++) {
    int pos1, t1, pos2, t2;
    scanf("%d", &pos1);
    scanf("%s", buf);
    t1 = typeToInt(buf[0]);
    scanf("%d", &pos2);
    scanf("%s", buf);
    t2 = typeToInt(buf[0]);
    pos1--;
    pos2--;
    addRule(pos1, t1, pos2, t2);
    addRule(pos2, (t2 ^ 1), pos1, (t1 ^ 1));
  }
  scanf("%s", buf);
  sChars = string(buf);
  for (int i = 0; i < n; i++) {
    s[i] = sChars[i] - 'a';
  }
  for (int i = 0; i < n; i++) {
    findObligatoryTypes(i);
  }
  for (int i = 0; i < n; i++) {
    if (isObligatory[i][0] && isObligatory[i][1]) NO();
    ansObligatoryType[i] = -1;
    for (int j = 0; j < 2; j++)
      if (isObligatory[i][j]) ansObligatoryType[i] = j;
  }
  haveAns = false;
  for (int i = 0; i <= n; i++) {
    tryAnswer(i);
  }
  if (!haveAns) NO();
  for (int i = 0; i < n; i++) printf("%c", 'a' + ans[i]);
  return 0;
}
