#include <bits/stdc++.h>
using namespace std;
const int OO = (int)2e9;
const double PI = 2 * acos(0);
const double EPS = 1e-9;
int dcmp(double a, double b) { return fabs(a - b) <= EPS ? 0 : a > b ? 1 : 2; }
int DI[] = {-1, 0, 1, 0, 1, -1, -1, 1};
int DJ[] = {0, 1, 0, -1, 1, -1, 1, -1};
vector<string> org;
string zbt(string l) {
  string ret = "";
  for (int i = 0; i < (int)(int)l.size(); i++) {
    if (l[i] == ';' || l[i] == '_' || l[i] == '-') continue;
    ret += tolower(l[i]);
  }
  return ret;
}
int main() {
  string in;
  int n;
  for (int i = 0; i < (int)3; i++) {
    cin >> in;
    org.push_back(zbt(in));
  }
  cin >> n;
  for (int i = 0; i < (int)n; i++) {
    cin >> in;
    in = zbt(in);
    sort(org.begin(), org.end());
    bool ok = 0;
    do {
      if (in == org[0] + org[1] + org[2]) {
        ok = 1;
        goto end;
      }
    } while (next_permutation(org.begin(), org.end()));
  end:;
    if (ok)
      cout << "ACC\n";
    else
      cout << "WA\n";
  }
  return 0;
}
