#include <bits/stdc++.h>
using namespace std;
void fast() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout << setprecision(12) << fixed;
}
void solve() {
  vector<string> v(3), v2(3);
  for (long long i = 0; i < 3; i++) cin >> v[i];
  char faltu[3] = {'-', '_', ';'};
  for (long long i = 0; i < 3; i++) {
    for (auto x : v[i]) {
      long long f = 0;
      for (auto y : faltu) {
        if (x == y) f = 1;
      }
      if (!f) v2[i] += tolower(x);
    }
  }
  vector<string> per;
  vector<long long> aa = {0, 1, 2};
  do {
    string s;
    for (long long i = 0; i < 3; i++) s += v2[aa[i]];
    per.push_back(s);
  } while (next_permutation(aa.begin(), aa.end()));
  long long q;
  cin >> q;
  while (q--) {
    string s, ss;
    cin >> s;
    for (auto x : s) {
      long long f = 0;
      for (auto y : faltu) {
        if (x == y) f = 1;
      }
      if (!f) ss += tolower(x);
    }
    long long f = 0;
    for (auto x : per) {
      if (x == ss) f = 1;
    }
    cout << (f ? "ACC" : "WA") << endl;
  }
}
int main() {
  fast();
  long long t = 1;
  while (t--) {
    solve();
  }
}
