#include <bits/stdc++.h>
using namespace std;
long long int power(long long int x, long long int y) {
  long long int res = 1;
  while (y) {
    if (y % 2 == 0) {
      x = (x * x);
      y /= 2;
    } else {
      res = (res * x);
      y--;
    }
  }
  return res;
}
void sieve() {
  vector<bool> prime(1e6 + 1, true);
  prime[0] = prime[1] = false;
  for (long long int i = 2; i * i <= 1e6; i++) {
    if (prime[i]) {
      for (long long int j = i * i; j <= 1e6; j += i) prime[j] = false;
    }
  }
}
bool is_Balanced_Parenthesis(string s) {
  stack<char> st;
  for (auto it : s) {
    if (it == '(' || it == '{' || it == '[') {
      st.push(it);
      continue;
    }
    if (st.empty()) return false;
    if (it == ')') {
      char ch = st.top();
      st.pop();
      if (ch != '(') return false;
    }
    if (it == ']') {
      char ch = st.top();
      st.pop();
      if (ch != '[') return false;
    }
    if (it == '}') {
      char ch = st.top();
      st.pop();
      if (ch != '{') return false;
    }
  }
  return st.empty();
}
void solve() {
  vector<string> ans;
  for (long long int i = 1; i <= 3; i++) {
    string s;
    cin >> s;
    string k = "";
    for (auto it : s) {
      if (isalpha(it)) {
        k += tolower(it);
      }
    }
    ans.push_back(k);
  }
  sort(ans.begin(), ans.end());
  set<string> st;
  do {
    string a = ans[0] + ans[1] + ans[2];
    st.insert(a);
  } while (next_permutation(ans.begin(), ans.end()));
  long long int n;
  cin >> n;
  while (n--) {
    string g;
    cin >> g;
    string h = "";
    for (auto it : g) {
      if (isalpha(it)) {
        h += tolower(it);
      }
    }
    if (st.find(h) != st.end())
      cout << "ACC"
           << "\n";
    else
      cout << "WA"
           << "\n";
  }
  return;
}
void c_p_c() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}
int32_t main() {
  c_p_c();
  solve();
  return 0;
}
