#include <bits/stdc++.h>
using namespace std;
int dx8[8] = {1, -1, 0, 0, 1, 1, -1, -1};
int dy8[8] = {0, 0, 1, -1, 1, -1, 1, -1};
void file() {}
void fast() {
  std::ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
}
vector<vector<int> > v;
vector<int> u;
int ans = 0;
void dfs(int node, int c) {
  u[node] = c;
  for (int i = 0; i < v[node].size(); i++)
    if (u[v[node][i]] == u[node])
      ans++, u[node] = 3;
    else if (!u[v[node][i]])
      dfs(v[node][i], 3 - c);
}
int main() {
  file();
  string a[3];
  cin >> a[0] >> a[1] >> a[2];
  for (int j = 0; j < 3; j++) {
    for (int i = 0; i < a[j].size(); i++) {
      if (!isalpha(a[j][i]))
        a[j].erase(i, 1), i = -1;
      else
        a[j][i] = tolower(a[j][i]);
    }
  }
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    string x;
    cin >> x;
    for (int i = 0; i < (int)x.size(); i++) {
      if (x[i] == '_' || !isalpha(x[i]))
        x.erase(i, 1), i = -1;
      else
        x[i] = tolower(x[i]);
    }
    if (x == a[0] + a[1] + a[2] || x == a[0] + a[2] + a[1] ||
        x == a[1] + a[2] + a[0] || x == a[1] + a[0] + a[2] ||
        x == a[2] + a[1] + a[0] || x == a[2] + a[0] + a[1])
      cout << "ACC" << endl;
    else
      cout << "WA" << endl;
  }
}
