#include <bits/stdc++.h>
using namespace std;
class Solution {
 public:
  void clean(string& s) {
    string t = "";
    for (int i = 0; i <= (int)s.size() - 1; i++) {
      if (isalpha(s[i])) t += s[i];
    }
    for (int i = 0; i <= (int)t.size() - 1; i++) t[i] = (char)tolower(t[i]);
    s = t;
  }
  void solve(std::istream& in, std::ostream& out) {
    string s1, s2, s3;
    in >> s1 >> s2 >> s3;
    clean(s1);
    clean(s2);
    clean(s3);
    if ((int)s1.size() < (int)s2.size()) s1.swap(s2);
    if ((int)s1.size() < (int)s3.size()) s1.swap(s3);
    if ((int)s2.size() < (int)s3.size()) s2.swap(s3);
    int n;
    in >> n;
    string s;
    for (int i = 1; i <= n; i++) {
      in >> s;
      clean(s);
      int pos;
      if ((pos = s.find(s1)) != s.npos) {
        for (int j = 0; j <= (int)s1.size() - 1; j++) s[pos + j] = '.';
      } else {
        out << "WA" << '\n';
        continue;
      }
      if ((pos = s.find(s2)) != s.npos) {
        for (int j = 0; j <= (int)s2.size() - 1; j++) s[pos + j] = '.';
      } else {
        out << "WA" << '\n';
        continue;
      }
      if ((pos = s.find(s3)) != s.npos) {
        for (int j = 0; j <= (int)s3.size() - 1; j++) s[pos + j] = '.';
      } else {
        out << "WA" << '\n';
        continue;
      }
      bool ok = true;
      for (int i = 0; i <= (int)s.size() - 1; i++)
        if (s[i] != '.') {
          ok = false;
          break;
        }
      if (ok)
        out << "ACC" << '\n';
      else
        out << "WA" << '\n';
    }
  }
};
void solve(std::istream& in, std::ostream& out) {
  out << fixed << std::setprecision(6);
  Solution solution;
  solution.solve(in, out);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  istream& in = cin;
  ostream& out = cout;
  solve(in, out);
  return 0;
}
