#include <bits/stdc++.h>
using namespace std;
string simplify(string s) {
  string a;
  for (int i = 0; i < s.length(); i++) {
    if (isalpha(s[i])) {
      s[i] = tolower(s[i]);
      a.push_back(s[i]);
    }
  }
  return a;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(NULL);
  string s1, s2, s3;
  cin >> s1 >> s2 >> s3;
  s1 = simplify(s1);
  s2 = simplify(s2);
  s3 = simplify(s3);
  int x = s1.length(), y = s2.length(), z = s3.length();
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    s = simplify(s);
    if (s.length() == x + y + z &&
        (s == s1 + s2 + s3 || s == s1 + s3 + s2 || s == s2 + s1 + s3 ||
         s == s2 + s3 + s1 || s == s3 + s1 + s2 || s == s3 + s2 + s1))
      cout << "ACC\n";
    else
      cout << "WA\n";
  }
}
