#include <bits/stdc++.h>
using namespace std;
string a[4];
void solve(string &st) {
  int i = -1, t = st.size();
  while (i < t) {
    i++;
    if (st[i] == '-' || st[i] == '_' || st[i] == ';') {
      st.erase(i, 1);
      t--;
      i--;
    } else if (st[i] >= 'A' && st[i] <= 'Z')
      st[i] += 32;
  }
}
string res(string st) {
  string case1, case2, case3, case4, case5, case6;
  case1 = a[1] + a[2] + a[3];
  case2 = a[1] + a[3] + a[2];
  case3 = a[2] + a[1] + a[3];
  case4 = a[2] + a[3] + a[1];
  case5 = a[3] + a[1] + a[2];
  case6 = a[3] + a[2] + a[1];
  if (st == case1 || st == case2 || st == case3 || st == case4 || st == case5 ||
      st == case6)
    return "ACC";
  return "WA";
}
int main() {
  for (int i = 1; i <= 3; i++) {
    getline(cin, a[i]);
    solve(a[i]);
  }
  int n;
  cin >> n;
  cin.ignore();
  string st;
  for (int i = 1; i <= n; i++) {
    getline(cin, st);
    if (st.size() > 600)
      cout << "WA";
    else {
      solve(st);
      cout << res(st) << endl;
    }
  }
  return 0;
}
