#include <bits/stdc++.h>
using namespace std;
string Clean(string s) {
  string t;
  for (int i = 0; i < s.length(); i++) {
    if (s[i] >= 'a' && s[i] <= 'z') t += s[i];
    if (s[i] >= 'A' && s[i] <= 'Z') t += tolower(s[i]);
  }
  return t;
}
int main() {
  string x, y, z, s, t;
  int i, n;
  cin >> x >> y >> z >> n;
  x = Clean(x);
  y = Clean(y);
  z = Clean(z);
  for (i = 1; i <= n; i++) {
    cin >> s;
    s = Clean(s);
    if (s == x + y + z || s == x + z + y || s == y + x + z || s == y + z + x ||
        s == z + y + x || s == z + x + y)
      cout << "ACC";
    else
      cout << "WA";
    cout << endl;
  }
  return 0;
}
