#include <bits/stdc++.h>
using namespace std;
string Normalize(const string& s) {
  string t;
  for (int i = 0, e__ = (s.size()); i < e__; ++i) {
    char c = s[i];
    if (isalpha(c)) t += tolower(c);
  }
  return t;
}
int main() {
  string a, b, c;
  while (cin >> a >> b >> c) {
    string ss[] = {a, b, c};
    for (int i = 0, e__ = (3); i < e__; ++i) ss[i] = Normalize(ss[i]);
    sort(ss, ss + 3);
    string perms[6];
    for (int i = 0, e__ = (6); i < e__; ++i) {
      for (int j = 0, e__ = (3); j < e__; ++j) perms[i] += ss[j];
      next_permutation(ss, ss + 3);
    }
    sort(perms, perms + 6);
    int N;
    cin >> N;
    for (int i = 0, e__ = (N); i < e__; ++i) {
      string s;
      cin >> s;
      s = Normalize(s);
      if (binary_search(perms, perms + 6, s)) {
        cout << "ACC" << endl;
      } else {
        cout << "WA" << endl;
      }
    }
  }
  return 0;
}
