#include <bits/stdc++.h>
using namespace std;
string clean(string s) {
  string ans = "";
  for (char c : s) {
    if (c != '-' && c != '_' && c != ';') {
      ans += tolower(c);
    }
  }
  return ans;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  string a, b, c;
  cin >> a >> b >> c;
  a = clean(a);
  b = clean(b);
  c = clean(c);
  string s1, s2, s3, s4, s5, s6;
  s1 = a + b + c;
  s2 = a + c + b;
  s3 = b + a + c;
  s4 = b + c + a;
  s5 = c + a + b;
  s6 = c + b + a;
  int n;
  cin >> n;
  while (n--) {
    string s;
    cin >> s;
    s = clean(s);
    if (s == s1 || s == s2 || s == s3 || s == s4 || s == s5 || s == s6)
      cout << "ACC\n";
    else
      cout << "WA\n";
  }
  return 0;
}
