#include <bits/stdc++.h>
using namespace std;
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  string a, b, c;
  cin >> a >> b >> c;
  for (long long int i = 0; i < (long long int)((a).size()); i++) {
    if (a[i] == '-' or a[i] == '_' or a[i] == ';') {
      a.erase(i, 1);
      i--;
    } else
      a[i] = tolower(a[i]);
  }
  for (long long int i = 0; i < (long long int)((b).size()); i++) {
    if (b[i] == '-' or b[i] == '_' or b[i] == ';') {
      b.erase(i, 1);
      i--;
    } else
      b[i] = tolower(b[i]);
  }
  for (long long int i = 0; i < (long long int)((c).size()); i++) {
    if (c[i] == '-' or c[i] == '_' or c[i] == ';') {
      c.erase(i, 1);
      i--;
    } else
      c[i] = tolower(c[i]);
  }
  unordered_set<string> str;
  str.insert(a + b + c);
  str.insert(a + c + b);
  str.insert(c + a + b);
  str.insert(c + b + a);
  str.insert(b + c + a);
  str.insert(b + a + c);
  long long int n;
  cin >> n, n *= 1;
  while (n--) {
    string s;
    cin >> s;
    for (long long int i = 0; i < (long long int)((s).size()); i++) {
      if (s[i] == '-' or s[i] == '_' or s[i] == ';') {
        s.erase(i, 1);
        i--;
      } else
        s[i] = tolower(s[i]);
    }
    if (str.find(s) != str.end())
      cout << "ACC\n";
    else
      cout << "WA\n";
  }
  return 0;
}
