#include <bits/stdc++.h>
using namespace std;
inline void normalize(string &s) {
  string t = "";
  for (char c : s) {
    if (isalpha(c)) {
      t += char(tolower(c));
    }
  }
  s = t;
}
int main() {
  ios_base::sync_with_stdio(false);
  string a[3];
  for (int i = 0; i < 3; ++i) {
    getline(cin, a[i]);
  }
  for (int i = 0; i < 3; ++i) {
    normalize(a[i]);
  }
  int p[3];
  p[0] = 0, p[1] = 1, p[2] = 2;
  vector<string> res;
  do {
    string tmp;
    for (int i = 0; i < 3; ++i) {
      tmp += a[p[i]];
    }
    res.push_back(tmp);
  } while (next_permutation(p, p + 3));
  int n;
  cin >> n;
  cin.ignore(1, '\n');
  for (int i = 0; i < n; ++i) {
    string s;
    getline(cin, s);
    normalize(s);
    bool ok = false;
    for (int j = 0; j < (int)res.size(); ++j) {
      if (s == res[j]) {
        ok = true;
      }
    }
    if (ok) {
      cout << "ACC\n";
    } else {
      cout << "WA\n";
    }
  }
  return 0;
}
