#include <bits/stdc++.h>
using namespace std;
int solve(string s) {
  int r = 0;
  for (int i = 0; i < s.length(); i++) {
    if (s[i] == '-' || s[i] == ';' || s[i] == '_') {
      r++;
    }
  }
  return r;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL), cout.tie(NULL);
  string a, b, c;
  cin >> a >> b >> c;
  transform(a.begin(), a.end(), a.begin(), ::tolower);
  transform(b.begin(), b.end(), b.begin(), ::tolower);
  transform(c.begin(), c.end(), c.begin(), ::tolower);
  int n = a.length() - solve(a), m = b.length() - solve(b),
      p = c.length() - solve(c);
  string v = "", u = "", w = "";
  int i = 0;
  for (i = 0; i < a.length(); i++) {
    if (a[i] != '-' && a[i] != '_' && a[i] != ';') {
      v += a[i];
    }
  }
  for (int i = 0; i < b.length(); i++) {
    if (b[i] != '-' && b[i] != '_' && b[i] != ';') {
      u += b[i];
    }
  }
  for (int i = 0; i < c.length(); i++) {
    if (c[i] != '-' && c[i] != '_' && c[i] != ';') {
      w += c[i];
    }
  }
  int t;
  cin >> t;
  while (t--) {
    string z;
    cin >> z;
    transform(z.begin(), z.end(), z.begin(), ::tolower);
    int cv = z.length() - solve(z);
    string bn = "";
    for (int i = 0; i < z.length(); i++) {
      if (z[i] != '-' && z[i] != ';' && z[i] != '_') {
        bn += z[i];
      }
    }
    int co = 0;
    if (bn == (v + u + w) && co != 1) {
      co = 1;
      cout << "ACC\n";
    }
    if (bn == (v + w + u) && co != 1) {
      co = 1;
      cout << "ACC\n";
    }
    if (bn == (u + v + w) && co != 1) {
      co = 1;
      cout << "ACC\n";
    }
    if (bn == (u + w + v) && co != 1) {
      co = 1;
      cout << "ACC\n";
    }
    if (bn == (w + u + v) && co != 1) {
      co = 1;
      cout << "ACC\n";
    }
    if (bn == (w + v + u) && co != 1) {
      co = 1;
      cout << "ACC\n";
    }
    if (co != 1) {
      cout << "WA\n";
    }
  }
  return 0;
}
