#include <bits/stdc++.h>
using namespace std;
typedef priority_queue<int> pqi1;
typedef priority_queue<int, vector<int>, greater<int>> pqi2;
string convert(string s) {
  string ans = "";
  for (char c : s) {
    if (isalpha(c)) {
      c = tolower(c);
      ans += c;
    }
  }
  return ans;
}
int main() {
  string a, b, c;
  cin >> a >> b >> c;
  a = convert(a);
  b = convert(b);
  c = convert(c);
  vector<string> comp;
  comp.push_back(a + b + c);
  comp.push_back(a + c + b);
  comp.push_back(b + a + c);
  comp.push_back(b + c + a);
  comp.push_back(c + a + b);
  comp.push_back(c + b + a);
  int n;
  cin >> n;
  while (n--) {
    string r;
    cin >> r;
    r = convert(r);
    bool found = false;
    for (auto k : comp) {
      if (r == k) {
        found = true;
      }
    }
    if (found) {
      cout << "ACC" << endl;
    } else {
      cout << "WA" << endl;
    }
  }
}
