#include <bits/stdc++.h>
using namespace std;
int main() {
  int t, i, count;
  char c;
  std::string str, str1, str2;
  vector<string> vs, store;
  for (t = 1; t <= 3; t++) {
    cin >> str;
    str2 = "";
    for (i = 0; i < str.length(); i++) {
      if (isalpha(str[i])) {
        stringstream ss;
        c = tolower(str[i]);
        ss << c;
        ss >> str1;
        str2.append(str1);
      }
    }
    vs.push_back(str2);
  }
  store.push_back(vs[0] + vs[1] + vs[2]);
  store.push_back(vs[0] + vs[2] + vs[1]);
  store.push_back(vs[1] + vs[2] + vs[0]);
  store.push_back(vs[1] + vs[0] + vs[2]);
  store.push_back(vs[2] + vs[1] + vs[0]);
  store.push_back(vs[2] + vs[0] + vs[1]);
  int num;
  cin >> num;
  for (t = 1; t <= num; t++) {
    cin >> str;
    str2 = "";
    for (i = 0; i < str.length(); i++) {
      if (isalpha(str[i])) {
        stringstream ss;
        c = tolower(str[i]);
        ss << c;
        ss >> str1;
        str2.append(str1);
      }
    }
    count = 0;
    for (i = 0; i < store.size(); i++) {
      if (store[i] == str2) count++;
    }
    if (count == 1)
      cout << "ACC" << endl;
    else
      cout << "WA" << endl;
  }
  return 0;
}
