#include <bits/stdc++.h>
using namespace std;
string filter(string x) {
  string res = "";
  for (int i = 0; i < x.size(); i++) {
    if (isalpha(x[i])) {
      res += tolower(x[i]);
    }
  }
  return res;
}
int main() {
  string p, q, r, x;
  cin >> p >> q >> r;
  p = filter(p);
  q = filter(q);
  r = filter(r);
  int n;
  cin >> n;
  while (n--) {
    cin >> x;
    x = filter(x);
    if (x == p + q + r || x == p + r + q || x == q + r + p || x == q + p + r ||
        x == r + p + q || x == r + q + p)
      cout << "ACC" << endl;
    else
      cout << "WA" << endl;
  }
}
