#include <bits/stdc++.h>
using namespace std;
string str, s, s2, s3;
vector<string> v, v2;
int n, flag = 0;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  for (int i = 0; i < 3; ++i) {
    cin >> str;
    transform(str.begin(), str.end(), str.begin(), ::tolower);
    for (int j = 0; j < str.length(); ++j)
      if (str[j] >= 'a' && str[j] <= 'z') s += str[j], s2 += str[j];
    v.push_back(s), s = "";
  }
  sort(v.begin(), v.end());
  do {
    s3 = "";
    for (auto i : v) s3 += i;
    v2.push_back(s3);
  } while (next_permutation(v.begin(), v.end()));
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> str;
    transform(str.begin(), str.end(), str.begin(), ::tolower);
    for (int j = 0; j < str.length(); ++j)
      if (str[j] >= 'a' && str[j] <= 'z') s += str[j];
    if (s.length() != s2.length())
      cout << "WA" << endl;
    else {
      flag = 0;
      for (auto k : v2)
        if (k == s) {
          flag = 1;
          break;
        }
      flag ? cout << "ACC" << endl : cout << "WA" << endl;
    }
    s = "";
  }
}
