#include <bits/stdc++.h>
using namespace std;
long long int factorial(int n) {
  if (n == 0 || n == 1) {
    return 1;
  } else {
    return n * factorial(n - 1);
  }
}
void file_i_o() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}
string prepro(string s) {
  string dum;
  int n = s.length();
  for (int i = 0; i <= n - 1; i++) {
    if (s[i] == ';' || s[i] == '_' || s[i] == '-') {
      continue;
    }
    dum += tolower(s[i]);
  }
  return dum;
}
bool check(string a, string b) {
  long long int l1 = a.length();
  long long int l2 = b.length();
  if (l1 != l2) return 0;
  for (int i = 0; i <= l1 - 1; i++) {
    if (a[i] != b[i] && (a[i])) return 0;
  }
  return 1;
}
std::vector<string> v(6);
int main() {
  file_i_o();
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  string a, b, c;
  cin >> a >> b >> c;
  a = prepro(a);
  b = prepro(b);
  c = prepro(c);
  int n;
  cin >> n;
  v[0] = a + b + c;
  v[1] = b + a + c;
  v[2] = c + a + b;
  v[3] = a + c + b;
  v[4] = b + c + a;
  v[5] = c + b + a;
  for (int i = 1; i <= n; i++) {
    string ck;
    cin >> ck;
    ck = prepro(ck);
    bool watch = false;
    for (int j = 0; j <= 5; j++) {
      watch = check(ck, v[j]);
      if (watch) {
        cout << "ACC\n";
        break;
      }
    }
    if (!watch) {
      cout << "WA\n";
    }
  }
  return 0;
}
