#include <bits/stdc++.h>
using namespace std;
string clr_word(string s) {
  string res;
  int l = s.size();
  for (int i = 0; i < l; i++) {
    if ((s[i] >= 'a' && s[i] <= 'z') || (s[i] >= 'A' && s[i] <= 'Z'))
      res.push_back(tolower(s[i]));
  }
  return res;
}
int main() {
  int n;
  string a, b, c, d;
  cin >> a >> b >> c >> n;
  a = clr_word(a);
  b = clr_word(b);
  c = clr_word(c);
  for (int i = 0; i < n; i++) {
    cin >> d;
    d = clr_word(d);
    if (d == a + b + c || d == a + c + b || d == b + a + c || d == b + c + a ||
        d == c + a + b || d == c + b + a)
      cout << "ACC" << endl;
    else
      cout << "WA" << endl;
  }
  return 0;
}
