#include <bits/stdc++.h>
using namespace std;
bool isACC(const string&);
string norm(string&);
int n;
int p[3];
string s;
string a[3];
string r[6];
int main(int argc, char** argv) {
  ios_base::sync_with_stdio(false);
  for (int i = 0; i < 3; ++i) {
    cin >> a[i];
    a[i] = norm(a[i]);
    p[i] = i;
  }
  int k = 0;
  do {
    r[k] = "";
    for (int i = 0; i < 3; ++i) {
      r[k] += a[p[i]];
    }
    k++;
  } while (next_permutation(p, p + 3));
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> s;
    cout << (isACC(norm(s)) ? "ACC\n" : "WA\n");
  }
  return EXIT_SUCCESS;
}
bool isACC(const string& s) {
  for (int i = 0; i < 6; ++i) {
    if (s == r[i]) {
      return true;
    }
  }
  return false;
}
string norm(string& s) {
  string t;
  for (int i = 0; i < (int)s.size(); ++i) {
    if (s[i] != ';' && s[i] != '_' && s[i] != '-') t += tolower(s[i]);
  }
  return t;
}
