#include <bits/stdc++.h>
using namespace std;
string ChuanHoa(string s0) {
  string a;
  for (int i = 0; i < s0.length(); i++) {
    if (s0[i] >= 65 && s0[i] <= 90) s0[i] += 32;
    if (s0[i] >= 97 && s0[i] <= 122) a += s0[i];
  }
  return a;
}
int main() {
  vector<string> v;
  string a, b, c, s0, s1, s2;
  cin >> s0 >> s1 >> s2;
  a = ChuanHoa(s0);
  b = ChuanHoa(s1);
  c = ChuanHoa(s2);
  v.push_back(a + b + c);
  v.push_back(a + c + b);
  v.push_back(b + a + c);
  v.push_back(b + c + a);
  v.push_back(c + a + b);
  v.push_back(c + b + a);
  int n, flag;
  cin >> n;
  string temp;
  vector<string> vt;
  for (int i = 0; i < n; i++) {
    cin >> temp;
    temp = ChuanHoa(temp);
    vt.push_back(temp);
  }
  for (int i = 0; i < n; i++) {
    flag = 0;
    for (int j = 0; j < 6; j++)
      if (vt[i] == v[j]) {
        cout << "ACC" << endl;
        flag = 1;
        break;
      }
    if (flag == 0) cout << "WA" << endl;
  }
  return 0;
}
