#include <bits/stdc++.h>
using namespace std;
int main() {
  string s, w, t;
  cin >> s >> w >> t;
  string s1 = "", w1 = "", t1 = "";
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == ';' || s[i] == '_' || s[i] == '-' || s[i] == ',')
      continue;
    else {
      s[i] = tolower(s[i]);
      s1 += s[i];
    }
  }
  for (int i = 0; i < w.size(); i++) {
    if (w[i] == ';' || w[i] == '_' || w[i] == '-' || w[i] == ',')
      continue;
    else {
      w[i] = tolower(w[i]);
      w1 += w[i];
    }
  }
  for (int i = 0; i < t.size(); i++) {
    if (t[i] == ';' || t[i] == '_' || t[i] == '-' || t[i] == ',')
      continue;
    else {
      t[i] = tolower(t[i]);
      t1 += t[i];
    }
  }
  string p1 = s1 + w1 + t1;
  string p2 = s1 + t1 + w1;
  string p3 = t1 + s1 + w1;
  string p4 = t1 + w1 + s1;
  string p5 = w1 + t1 + s1;
  string p6 = w1 + s1 + t1;
  int n;
  cin >> n;
  string r, z = "";
  while (n--) {
    cin >> r;
    for (int i = 0; i < r.size(); i++) {
      if (r[i] == ';' || r[i] == '_' || r[i] == '-' || r[i] == ',')
        continue;
      else {
        r[i] = tolower(r[i]);
        z += r[i];
      }
    }
    if (z == p1 || z == p2 || z == p3 || z == p4 || z == p5 || z == p6)
      cout << "ACC\n";
    else
      cout << "WA\n";
    z = "";
  }
}
