#include <bits/stdc++.h>
using namespace std;
string s[3];
int permutation[6][3] = {{0, 1, 2}, {0, 2, 1}, {1, 0, 2},
                         {1, 2, 0}, {2, 0, 1}, {2, 1, 0}};
string accepted_strings[6];
string process(string str) {
  string result = "";
  for (int i = 0; i < (int)str.length(); i++) {
    if (str[i] == '-' || str[i] == ';' || str[i] == '_') {
      continue;
    }
    if (isupper(str[i])) {
      result += str[i] + 32;
      continue;
    }
    result += str[i];
  }
  return result;
}
string genString(int i) {
  string result = "";
  for (int j = 0; j < 3; j++) {
    result += s[permutation[i][j]];
  }
  return result;
}
void solve() {
  cin >> s[0] >> s[1] >> s[2];
  s[0] = process(s[0]);
  s[1] = process(s[1]);
  s[2] = process(s[2]);
  for (int i = 0; i < 6; i++) {
    accepted_strings[i] = genString(i);
  }
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    string t;
    cin >> t;
    t = process(t);
    bool acc = false;
    for (int j = 0; j < 6; j++) {
      if (t == accepted_strings[j]) {
        acc = true;
        break;
      }
    }
    if (acc) {
      cout << "ACC\n";
    } else {
      cout << "WA\n";
    }
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  solve();
  return 0;
}
