#include <bits/stdc++.h>
using namespace std;
string s(string str) {
  string res;
  for (int i = 0; i < (int)str.size(); ++i) {
    if (str[i] == '_' || str[i] == ';' || str[i] == '-') continue;
    res += str[i];
  }
  for (int i = 0; i < (int)res.size(); i++) {
    res[i] = tolower(res[i]);
  }
  return res;
}
int main() {
  string _a, _b, _c;
  while (cin >> _a >> _b >> _c) {
    string abc[3];
    abc[0] = s(_a);
    abc[1] = s(_b);
    abc[2] = s(_c);
    set<string> abcPerm;
    sort(abc, abc + 3);
    do {
      string str;
      for (int i = 0; i < 3; ++i) {
        str += abc[i];
      }
      abcPerm.insert(str);
    } while (next_permutation(abc, abc + 3));
    int x;
    cin >> x;
    while (x--) {
      string in;
      cin >> in;
      in = s(in);
      string res = (abcPerm.find(in) != abcPerm.end()) ? "ACC" : "WA";
      cout << res << endl;
    }
  }
  return 0;
}
