#include <bits/stdc++.h>
using namespace std;
string concad(vector<string> v) {
  string s = "";
  for (int i = 0; i < v.size(); i++) s += v[i];
  return s;
}
string par(string s) {
  string r;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == ' ' || s[i] == '_' || s[i] == '-' || s[i] == ';') continue;
    if (s[i] < 'a' || s[i] > 'z')
      r.push_back(s[i] - 'A' + 'a');
    else
      r.push_back(s[i]);
  }
  return r;
}
int main() {
  int m;
  string s;
  vector<string> v, b;
  for (int i = 0; i < 3; i++) {
    getline(cin, s);
    v.push_back(par(s));
  }
  sort(v.begin(), v.end());
  do {
    b.push_back(concad(v));
  } while (next_permutation((v).begin(), (v).end()));
  cin >> m;
  for (int i = 0; i < m; i++) {
    cin >> s;
    string ww = par(s);
    bool l = 0;
    for (int j = 0; j < b.size(); j++) {
      if (ww == b[j]) {
        cout << "ACC" << endl;
        l = 1;
      }
    }
    if (!l) cout << "WA" << endl;
  }
}
