#include <bits/stdc++.h>
using namespace std;
void new_s(const string &&tmp, string &s1) {
  for (int i = 0; i < (int)tmp.size(); ++i) {
    if (isalpha(tmp[i])) {
      s1 += char(tolower(tmp[i]));
    }
  }
}
bool check_s(const vector<string> &v, const string &tmp) {
  string tmp2 = "";
  for (int i = 0; i < 3; ++i) {
    for (int j = 0; j < 3; ++j) {
      if (i == j) continue;
      for (int k = 0; k < 3; ++k) {
        if (k == j || k == i) continue;
        tmp2 = v[i] + v[j] + v[k];
        if (tmp == tmp2) return 1;
      }
    }
  }
  return 0;
}
signed main() {
  string s1, s2, s3, tmp, s;
  vector<string> v;
  v.resize(3);
  cin >> tmp;
  new_s(move(tmp), v[0]);
  cin >> tmp;
  new_s(move(tmp), v[1]);
  cin >> tmp;
  new_s(move(tmp), v[2]);
  int n;
  cin >> n;
  while (n--) {
    cin >> tmp;
    new_s(move(tmp), s);
    if (false) cerr << s << '\n';
    if (check_s(v, s))
      cout << "ACC\n";
    else
      cout << "WA\n";
    s = "";
  }
}
