#include <bits/stdc++.h>
using namespace std;
const int mod = 1000003;
long double pi = 3.1415926536;
const int mx = 1000003;
long long gcd(long long x, long long y) {
  if (y == 0) return x;
  return gcd(y, x % y);
}
long long bp(long long a, long long b) {
  long long ans = 1;
  while (b > 0) {
    if (b & 1) ans = (ans * a) % mod;
    a = (a * a) % mod;
    b >>= 1;
  }
  return ans;
}
long long p(long long n) {
  for (long long i = 2; i * i <= n; i++) {
    if (n % i == 0) {
      return n / i;
    }
  }
  return 1;
}
vector<long long> z(string s) {
  long long n = s.size();
  vector<long long> z(n);
  long long x = 0, y = 0, p = 0;
  for (long long i = 1; i < n; i++) {
    z[i] = max(p, min(z[i - x], y - i + 1));
    while (i + z[i] < n && s[z[i]] == s[i + z[i]]) {
      x = i;
      y = i + z[i];
      z[i]++;
    }
  }
  return z;
}
string f(string s) {
  string p = "";
  for (int i = 0; i < s.length(); i++)
    if (isalpha(s[i])) p += toupper(s[i]);
  return p;
}
int main() {
  string s, p, A, B, C;
  cin >> A >> B >> C;
  A = f(A);
  B = f(B);
  C = f(C);
  int n, i, j;
  cin >> n;
  while (n--) {
    cin >> s;
    s = f(s);
    if (s == A + B + C || s == A + C + B || s == B + C + A || s == B + A + C ||
        s == C + A + B || s == C + B + A)
      cout << "ACC" << endl;
    else
      cout << "WA" << endl;
  }
  return 0;
}
