#include <bits/stdc++.h>
using namespace std;
bool isSpecialCharecters(char character) {
  switch (character) {
    case ';':
      return true;
    case '_':
      return true;
    case '-':
      return true;
  }
  return false;
}
string filterSpecialCharacters(string input) {
  string output = "";
  string::iterator it;
  for (it = input.begin(); it != input.end(); it++) {
    if (!isSpecialCharecters(*it)) {
      output += tolower(*it);
    }
  }
  return output;
}
bool isAnswerRight(string answer, vector<string> rules) {
  string temp = "";
  string copyAnswer = answer;
  for (int i = 0; i < rules.size(); i++) {
    int position = (int)copyAnswer.find(rules[i]);
    if (position == -1) {
      return false;
    } else {
      copyAnswer.replace(copyAnswer.begin() + position,
                         copyAnswer.begin() + position + rules[i].size(), "1");
      temp.append(rules[i]);
    }
  }
  if (answer.size() > temp.size()) {
    return false;
  }
  return true;
}
int main(int argc, const char* argv[]) {
  string inputOne;
  string inputTwo;
  string inputThree;
  getline(cin, inputOne);
  getline(cin, inputTwo);
  getline(cin, inputThree);
  inputOne = filterSpecialCharacters(inputOne);
  inputTwo = filterSpecialCharacters(inputTwo);
  inputThree = filterSpecialCharacters(inputThree);
  int students;
  cin >> students;
  vector<string> answersOfStudents;
  vector<string> leters;
  leters.push_back(inputOne);
  leters.push_back(inputTwo);
  leters.push_back(inputThree);
  sort(leters.begin(), leters.end(),
       [](string a, string b) { return b.size() < a.size(); });
  for (int i = 0; i < students + 1; i++) {
    string value = "";
    getline(cin, value);
    if (!value.empty()) {
      value = filterSpecialCharacters(value);
      answersOfStudents.push_back(value);
    }
  }
  for (int i = 0; i < students; i++) {
    if (isAnswerRight(answersOfStudents[i], leters)) {
      cout << "ACC" << endl;
    } else {
      cout << "WA" << endl;
    }
  }
  return 0;
}
