#include <bits/stdc++.h>
using namespace std;
string a, b, c, r[10], s, rr;
int n;
string nrm(string s) {
  string r = "";
  for (int i = 0; i < s.length(); i++)
    if ((s[i] != '-') && (s[i] != ';') && (s[i] != '_')) r += tolower(s[i]);
  return r;
}
int main() {
  cin >> a >> b >> c;
  a = nrm(a);
  b = nrm(b);
  c = nrm(c);
  r[1] = a + b + c;
  r[2] = a + c + b;
  r[3] = b + a + c;
  r[4] = b + c + a;
  r[5] = c + a + b;
  r[6] = c + b + a;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> s;
    s = nrm(s);
    if ((s == r[1]) || (s == r[2]) || (s == r[3]) || (s == r[4]) ||
        (s == r[5]) || (s == r[6]))
      rr += "ACC\n";
    else
      rr += "WA\n";
  }
  cout << rr;
  return 0;
}
