#include <bits/stdc++.h>
using namespace std;
const long long mod = 998244353;
template <class nmsl>
inline void read(nmsl &x) {
  x = 0;
  char ch = getchar(), w = 0;
  while (!isdigit(ch)) w = (ch == '-'), ch = getchar();
  while (isdigit(ch)) x = (x << 1) + (x << 3) + (ch ^ 48), ch = getchar();
  x = w ? -x : x;
}
long long power(long long x, long long y, long long z) {
  x = (x % z);
  long long res = 1LL;
  while (y > 0) {
    if (y & 1) {
      res = (res * x) % z;
    }
    x = (x * x) % z;
    y = y >> 1;
  }
  return res;
}
long long modInv(long long n, long long mod) { return power(n, mod - 2, mod); }
long long nCrModP(long long n, long long r, long long mod) {
  if (r == 0) return 1;
  long long fac[n + 1];
  fac[0] = 1;
  for (long long i = 1; i <= n; i++) fac[i] = fac[i - 1] * i % mod;
  return (fac[n] * modInv(fac[r], mod) % mod * modInv(fac[n - r], mod) % mod) %
         mod;
}
long long countSetBits(long long n) {
  long long count = 0;
  while (n) {
    n &= (n - 1);
    count++;
  }
  return count;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  string a, b, c;
  cin >> a >> b >> c;
  string chars = "_-;";
  transform(a.begin(), a.end(), a.begin(), ::tolower);
  transform(b.begin(), b.end(), b.begin(), ::tolower);
  transform(c.begin(), c.end(), c.begin(), ::tolower);
  int n;
  cin >> n;
  for (char child : chars) {
    a.erase(remove(a.begin(), a.end(), child), a.end());
    b.erase(remove(b.begin(), b.end(), child), b.end());
    c.erase(remove(c.begin(), c.end(), child), c.end());
  }
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    transform(s.begin(), s.end(), s.begin(), ::tolower);
    for (char child : chars) {
      s.erase(remove(s.begin(), s.end(), child), s.end());
    }
    if (a + b + c == s || a + c + b == s || b + a + c == s || b + c + a == s ||
        c + a + b == s || c + b + a == s)
      cout << "ACC" << endl;
    else
      cout << "WA" << endl;
  }
  return 0;
}
