#include <bits/stdc++.h>
using namespace std;
int main() {
  string a, b, c;
  cin >> a >> b >> c;
  string a1 = "", b1 = "", c1 = "";
  long long int mx_l = max(a.length(), max(b.length(), c.length()));
  for (int i = 0; i < mx_l; i++) {
    if ((a[i] <= 'z' && a[i] >= 'a') || (a[i] <= 'Z' && a[i] >= 'A')) {
      if (i < a.length()) {
        a[i] = tolower(a[i]);
        a1.push_back(a[i]);
      }
    }
    if ((b[i] <= 'z' && b[i] >= 'a') || (b[i] <= 'Z' && b[i] >= 'A')) {
      if (i < b.length()) {
        b[i] = tolower(b[i]);
        b1.push_back(b[i]);
      }
    }
    if ((c[i] <= 'z' && c[i] >= 'a') || (c[i] <= 'Z' && c[i] >= 'A')) {
      if (i < c.length()) {
        c[i] = tolower(c[i]);
        c1.push_back(c[i]);
      }
    }
  }
  string t1 = a1 + b1 + c1;
  string t2 = b1 + a1 + c1;
  string t3 = b1 + c1 + a1;
  string t4 = a1 + c1 + b1;
  string t5 = c1 + b1 + a1;
  string t6 = c1 + a1 + b1;
  vector<string> test;
  test.push_back(t1);
  test.push_back(t2);
  test.push_back(t3);
  test.push_back(t4);
  test.push_back(t5);
  test.push_back(t6);
  long long int t;
  cin >> t;
  while (t--) {
    string s;
    cin >> s;
    string real = "";
    for (int i = 0; i < s.length(); i++) {
      if ((s[i] <= 'z' && s[i] >= 'a') || (s[i] <= 'Z' && s[i] >= 'A')) {
        s[i] = tolower(s[i]);
        real.push_back(s[i]);
      }
    }
    if (find(test.begin(), test.end(), real) != test.end())
      cout << "ACC" << endl;
    else
      cout << "WA" << endl;
  }
  return 0;
}
