#include <bits/stdc++.h>
using namespace std;
using namespace std::chrono;
void solve() {
  string s1, s2, s3;
  cin >> s1 >> s2 >> s3;
  string s = "";
  for (long long int i = 0; i < s1.size(); i++) {
    if (s1[i] != ';' && s1[i] != '-' && s1[i] != '_') {
      if (s1[i] <= 'Z') {
        s1[i] = s1[i] + 32;
      }
      s += s1[i];
    }
  }
  s1 = s;
  s = "";
  for (long long int i = 0; i < s2.size(); i++) {
    if (s2[i] != ';' && s2[i] != '-' && s2[i] != '_') {
      if (s2[i] <= 'Z') {
        s2[i] = s2[i] + 32;
      }
      s += s2[i];
    }
  }
  s2 = s;
  s = "";
  s = "";
  for (long long int i = 0; i < s3.size(); i++) {
    if (s3[i] != ';' && s3[i] != '-' && s3[i] != '_') {
      if (s3[i] <= 'Z') {
        s3[i] = s3[i] + 32;
      }
      s += s3[i];
    }
  }
  s3 = s;
  long long int t;
  cin >> t;
  while (t--) {
    cin >> s;
    string a;
    for (long long int i = 0; i < s.size(); i++) {
      if (s[i] != ';' && s[i] != '-' && s[i] != '_') {
        if (s[i] <= 'Z') {
          s[i] = s[i] + 32;
        }
        a += s[i];
      }
    }
    s = a;
    if (s1 + s2 + s3 == s || s1 + s3 + s2 == s || s2 + s1 + s3 == s ||
        s2 + s3 + s1 == s || s3 + s1 + s2 == s || s3 + s2 + s1 == s) {
      cout << "ACC\n";
    } else {
      cout << "WA\n";
    }
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(nullptr);
  cout.tie(0);
  auto start = high_resolution_clock::now();
  long long int p = 0;
  if (p) {
    long long int t;
    cin >> t;
    while (t--) solve();
  } else {
    solve();
  }
  auto stop = high_resolution_clock::now();
  auto duration = duration_cast<microseconds>(stop - start);
  return 0;
}
