#include <bits/stdc++.h>
using namespace std;
string converted() {
  string s;
  cin >> s;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] >= 'A' && s[i] <= 'Z')
      s[i] += 32;
    else if (s[i] == '-' || s[i] == '_' || s[i] == ';')
      s.erase(s.begin() + i), i--;
  }
  return s;
}
int main() {
  vector<pair<long long int, string>> s(3);
  long long int t_s = 0;
  for (int i = 0; i < 3; i++) {
    string p = converted();
    s[i] = {p.size(), p};
    t_s += p.size();
  }
  sort(s.rbegin(), s.rend());
  long long int n;
  cin >> n;
  while (n--) {
    string p = converted();
    long long int N = p.size(), count = 0;
    for (int j = 0; j < 3; j++) {
      for (int i = 0; i <= N - s[j].first; i++) {
        if (p.substr(i, s[j].first) == s[j].second) {
          for (int k = i; k < i + s[j].first; k++) p[k] = '-';
          count++;
          break;
        }
      }
    }
    if (count == 3 && N == t_s)
      cout << "ACC" << endl;
    else
      cout << "WA" << endl;
  }
}
