#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  string s1, s2, s3, c = ";-_";
  cin >> s1 >> s2 >> s3;
  for (int i = 0; i < s1.size(); i++) {
    if (c.find(s1[i]) != -1) {
      s1.erase(i, 1);
      i--;
    } else
      s1[i] = tolower(s1[i]);
  }
  for (int i = 0; i < s2.size(); i++) {
    if (c.find(s2[i]) != -1) {
      s2.erase(i, 1);
      i--;
    } else
      s2[i] = tolower(s2[i]);
  }
  for (int i = 0; i < s3.size(); i++) {
    if (c.find(s3[i]) != -1) {
      s3.erase(i, 1);
      i--;
    } else
      s3[i] = tolower(s3[i]);
  }
  string c1 = s1 + s2 + s3;
  string c2 = s2 + s1 + s3;
  string c3 = s3 + s1 + s2;
  string c4 = s1 + s3 + s2;
  string c5 = s2 + s3 + s1;
  string c6 = s3 + s2 + s1;
  vector<string> ans;
  int n;
  cin >> n;
  string t;
  for (int i = 0; i < n; i++) {
    cin >> t;
    for (int i = 0; i < t.size(); i++) {
      if (c.find(t[i]) != -1) {
        t.erase(i, 1);
        i--;
      } else
        t[i] = tolower(t[i]);
    }
    if (t == c1 || t == c2 || t == c3 || t == c4 || t == c5 || t == c6)
      ans.push_back("ACC");
    else
      ans.push_back("WA");
  }
  for (int i = 0; i < ans.size(); i++) cout << ans[i] << '\n';
  return 0;
}
