#include <bits/stdc++.h>
using namespace std;
int n;
string s, test;
string word[5];
bool isLet(char c) {
  if (('a' <= c && c <= 'z') || ('A' <= c && c <= 'Z')) return true;
  return false;
}
bool ok(string s) {
  if ((word[1] + word[2] + word[3] == s) ||
      (word[1] + word[3] + word[2] == s) ||
      (word[2] + word[1] + word[3] == s) ||
      (word[2] + word[3] + word[1] == s) ||
      (word[3] + word[1] + word[2] == s) || (word[3] + word[2] + word[1] == s))
    return true;
  return false;
}
char lowCase(char c) {
  if ('A' <= c && c <= 'Z') return c + 32;
  return c;
}
int main() {
  for (int i = 1; i <= 3; ++i) {
    cin >> s;
    for (int j = 0; j < s.size(); ++j)
      if (isLet(s[j])) word[i].push_back(lowCase(s[j]));
  }
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    test.clear();
    cin >> s;
    for (int j = 0; j < s.size(); ++j)
      if (isLet(s[j])) test.push_back(lowCase(s[j]));
    if (ok(test)) {
      cout << "ACC\n";
      continue;
    } else {
      cout << "WA\n";
      continue;
    }
  }
}
