#include <bits/stdc++.h>
using namespace std;
string saaf(string s) {
  string ans = "";
  for (int i = 0; i < s.length(); i++) {
    if (s[i] >= 'A' && s[i] <= 'Z')
      ans += s[i];
    else if (s[i] >= 'a' && s[i] <= 'z')
      ans += (s[i] - 'a' + 'A');
  }
  return ans;
}
void solve() {
  string a1, b1, c1;
  cin >> a1 >> b1 >> c1;
  string a = saaf(a1), b = saaf(b1), c = saaf(c1);
  int p;
  cin >> p;
  vector<string> answer;
  for (int i = 0; i < p; i++) {
    string test1;
    cin >> test1;
    string test = saaf(test1);
    if (test == a + b + c || test == a + c + b || test == b + a + c ||
        test == b + c + a || test == c + a + b || test == c + b + a)
      answer.push_back("ACC");
    else
      answer.push_back("WA");
  }
  for (auto i : answer) cout << i << endl;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  bool multi_run = 0;
  if (multi_run) {
    int t;
    cin >> t;
    while (t--) solve();
  } else {
    solve();
  }
}
