#include <bits/stdc++.h>
using namespace std;
string a, b, c;
string xa, xb, xc;
int n;
string t;
int main() {
  cin >> a >> b >> c;
  xa = xb = xc = "";
  for (int i = 0; i < a.length(); ++i)
    if (isalpha(a[i])) xa += tolower(a[i]);
  for (int i = 0; i < b.length(); ++i)
    if (isalpha(b[i])) xb += tolower(b[i]);
  for (int i = 0; i < c.length(); ++i)
    if (isalpha(c[i])) xc += tolower(c[i]);
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> t;
    string xt = "";
    for (int i = 0; i < t.length(); ++i)
      if (isalpha(t[i])) xt += tolower(t[i]);
    vector<string> vt;
    vt.push_back(xa);
    vt.push_back(xb);
    vt.push_back(xc);
    bool gd = false;
    sort(vt.begin(), vt.end());
    do {
      if (vt[0] + vt[1] + vt[2] == xt) gd = true;
    } while (next_permutation(vt.begin(), vt.end()));
    if (gd)
      cout << "ACC" << endl;
    else
      cout << "WA" << endl;
  }
  return 0;
}
