#include <bits/stdc++.h>
using namespace std;
string convert(string s) {
  string output("");
  for (int p = 0; p < s.size(); p++) {
    if ('a' <= s[p] && s[p] <= 'z') {
      output += s[p];
    } else if ('A' <= s[p] && s[p] <= 'Z') {
      output += (s[p] - 'A' + 'a');
    }
  }
  return output;
}
int main() {
  string a, b, c, d = "", e = "", f = "";
  cin >> a >> b >> c;
  a = convert(a);
  b = convert(b);
  c = convert(c);
  int n;
  cin >> n;
  string x;
  while (n--) {
    cin >> x;
    x = convert(x);
    if (x == a + b + c || x == a + c + b || x == b + a + c || x == b + c + a ||
        x == c + a + b || x == c + b + a) {
      cout << "ACC" << endl;
    } else {
      cout << "WA" << endl;
    }
  }
  return 0;
}
