#include <bits/stdc++.h>
using namespace std;
string s[3], a[6];
bool p[3] = {};
int x = 0;
void f(string t, int c) {
  if (c == 3) {
    a[x++] = t;
    return;
  }
  for (int i = 0; i < 3; i++)
    if (p[i] == 0) {
      p[i] = 1;
      f(t + s[i], c + 1);
      p[i] = 0;
    }
}
int main() {
  int n, sz;
  string arr[1002], t;
  cin >> s[0] >> s[1] >> s[2];
  cin >> n;
  for (int i = 0; i < n; i++) cin >> arr[i];
  for (int i = 0; i < 3; i++) {
    sz = s[i].size();
    t = "";
    for (int j = 0; j < sz; j++)
      if (isalpha(s[i][j])) t += tolower(s[i][j]);
    s[i] = t;
  }
  for (int i = 0; i < n; i++) {
    sz = arr[i].size();
    t = "";
    for (int j = 0; j < sz; j++)
      if (isalpha(arr[i][j])) t += tolower(arr[i][j]);
    arr[i] = t;
  }
  f("", 0);
  for (int i = 0; i < n; i++) {
    bool f = 1;
    for (int j = 0; j < 6; j++)
      if (arr[i] == a[j]) {
        cout << "ACC" << endl;
        f = 0;
        break;
      }
    if (f) cout << "WA" << endl;
  }
  return 0;
}
