#include <bits/stdc++.h>
using namespace std;
const long long OO = 1e8;
const double EPS = (1e-7);
int dcmp(double x, double y) { return fabs(x - y) <= EPS ? 0 : x < y ? -1 : 1; }
const int N = 100;
int main() {
  ios::sync_with_stdio(false);
  string s[3];
  cin >> s[0] >> s[1] >> s[2];
  for (int i = 0; i < (int)(3); ++i) {
    string temp;
    for (int j = 0; j < ((int)((s[i]).size())); ++j) {
      if (s[i][j] == '-' || s[i][j] == '_' || s[i][j] == ';') continue;
      if (s[i][j] >= 'A' && s[i][j] <= 'Z') s[i][j] = 'a' + (s[i][j] - 'A');
      temp.push_back(s[i][j]);
    }
    s[i] = temp;
  }
  set<string> words;
  for (int i = 0; i < (int)(3); ++i) {
    for (int j = 0; j < (int)(3); ++j) {
      for (int z = 0; z < (int)(3); ++z) {
        if (i == j || j == z || i == z) continue;
        words.insert(s[i] + s[j] + s[z]);
      }
    }
  }
  int n;
  cin >> n;
  for (int i = 0; i < (int)(n); ++i) {
    string temp;
    cin >> temp;
    string ss;
    for (int j = 0; j < ((int)((temp).size())); ++j) {
      if (temp[j] == '\n') break;
      if (temp[j] == '-' || temp[j] == '_' || temp[j] == ';') continue;
      if (temp[j] >= 'A' && temp[j] <= 'Z') temp[j] = 'a' + (temp[j] - 'A');
      ss.push_back(temp[j]);
    }
    if (words.find(ss) != words.end())
      cout << "ACC" << endl;
    else
      cout << "WA" << endl;
  }
  return 0;
}
