#include <bits/stdc++.h>
#pragma GCC optimize("03")
#pragma GCC target("sse4")
using namespace std;
const int mod = 100000007;
void rep(string e, string first, string replaceStr) {
  size_t pos = e.find(first);
  while (pos != string::npos) {
    e.replace(pos, (long long)(first).size(), replaceStr);
    break;
  }
  return;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  string a, b, c;
  cin >> a >> b >> c;
  int t;
  cin >> t;
  transform(a.begin(), a.end(), a.begin(), ::tolower);
  transform(b.begin(), b.end(), b.begin(), ::tolower);
  transform(c.begin(), c.end(), c.begin(), ::tolower);
  a.erase(remove(a.begin(), a.end(), '-'), a.end());
  a.erase(remove(a.begin(), a.end(), '_'), a.end());
  a.erase(remove(a.begin(), a.end(), ';'), a.end());
  b.erase(remove(b.begin(), b.end(), '-'), b.end());
  b.erase(remove(b.begin(), b.end(), '_'), b.end());
  b.erase(remove(b.begin(), b.end(), ';'), b.end());
  c.erase(remove(c.begin(), c.end(), '-'), c.end());
  c.erase(remove(c.begin(), c.end(), '_'), c.end());
  c.erase(remove(c.begin(), c.end(), ';'), c.end());
  vector<string> vec;
  vec.push_back(a + b + c);
  vec.push_back(b + a + c);
  vec.push_back(b + c + a);
  vec.push_back(a + c + b);
  vec.push_back(c + b + a);
  vec.push_back(c + a + b);
  while (t--) {
    string second;
    cin >> second;
    transform(second.begin(), second.end(), second.begin(), ::tolower);
    second.erase(remove(second.begin(), second.end(), '-'), second.end());
    second.erase(remove(second.begin(), second.end(), '_'), second.end());
    second.erase(remove(second.begin(), second.end(), ';'), second.end());
    int flag = 0;
    for (auto x : vec) {
      if (x == second) {
        flag = 1;
        break;
      }
    }
    if (flag) {
      cout << "ACC"
           << "\n";
    } else {
      cout << "WA"
           << "\n";
    }
  }
}
