#include <bits/stdc++.h>
using namespace std;
string src[3];
set<string> ok;
string read() {
  string s;
  cin >> s;
  string s1;
  for (int i = 0; i < ((int)s.size()); ++i)
    if (s[i] != '_' && s[i] != '-' && s[i] != ';') s1 += tolower(s[i]);
  return s1;
}
bool dp[100000];
void solve() {
  string s = read();
  if (ok.count(s))
    cout << "ACC";
  else
    cout << "WA";
  cout << endl;
}
int main(int argc, char* argv[]) {
  for (int i = 0; i < (3); ++i) src[i] = read();
  sort(src, src + 3);
  do {
    ok.insert(src[0] + src[1] + src[2]);
  } while (next_permutation(src, src + 3));
  int n;
  cin >> n;
  while (n--) solve();
  return 0;
}
