#include <bits/stdc++.h>
using namespace std;
string trans(string s) {
  string res = "";
  for (int i = 0; i < s.size(); i++) {
    if (s[i] >= 'a' && s[i] <= 'z') res += s[i];
    if (s[i] >= 'A' && s[i] <= 'Z') res += s[i] - 'A' + 'a';
  }
  return res;
}
int main() {
  string str[3], ex[6];
  for (int i = 0; i < 3; i++) {
    cin >> str[i];
    str[i] = trans(str[i]);
  }
  ex[0] = str[0] + str[1] + str[2];
  ex[1] = str[0] + str[2] + str[1];
  ex[2] = str[1] + str[0] + str[2];
  ex[3] = str[1] + str[2] + str[0];
  ex[4] = str[2] + str[0] + str[1];
  ex[5] = str[2] + str[1] + str[0];
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    s = trans(s);
    bool ok = false;
    for (int j = 0; j < 6; j++) {
      if (ex[j] == s) {
        cout << "ACC\n";
        ok = true;
        break;
      }
    }
    if (!ok) cout << "WA\n";
  }
  return 0;
}
