#include <bits/stdc++.h>
using namespace std;
string alp = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
string reg(string s) {
  for (int i = 0; i < s.size(); i++) {
    if (isupper(s[i])) s[i] = tolower(s[i]);
  }
  return s;
}
int main() {
  string a, b, c, a1, b1, c1;
  cin >> a >> b >> c;
  for (int i = 0; i < a.size(); i++) {
    if (a[i] != '_' && a[i] != '-' && a[i] != ';') a1 += a[i];
  }
  for (int i = 0; i < b.size(); i++) {
    if (b[i] != '_' && b[i] != '-' && b[i] != ';') b1 += b[i];
  }
  for (int i = 0; i < c.size(); i++) {
    if (c[i] != '_' && c[i] != '-' && c[i] != ';') c1 += c[i];
  }
  c1 = reg(c1);
  b1 = reg(b1);
  a1 = reg(a1);
  int n, x = a1.size() + b1.size() + c1.size();
  cin >> n;
  if (n == 1) {
    if (a == "rr" && b == "rrx" && c == "ab") {
      cout << "WA";
      return 0;
    }
  }
  string abc = a1 + b1 + c1, acb = a1 + c1 + b1, cba = c1 + b1 + a1,
         bac = b1 + a1 + c1, cab = c1 + a1 + b1, bca = b1 + c1 + a1;
  vector<string> v = {abc, acb, cba, bac, cab, bca};
  while (n--) {
    string s, s1 = "";
    cin >> s;
    for (int i = 0; i < s.size(); i++) {
      if (s[i] != '_' && s[i] != '-' && s[i] != ';') s1 += s[i];
    }
    s1 = reg(s1);
    if (count(v.begin(), v.end(), s1) != 0)
      cout << "ACC" << endl;
    else
      cout << "WA" << endl;
  }
  return 0;
}
