#include <bits/stdc++.h>
using namespace std;
set<string> tt;
char buf[1024];
int main() {
  int i, j, k;
  string s[3], t;
  int m, n;
  for (i = 0; i < 3; ++i) {
    cin >> buf;
    for (j = 0; buf[j]; ++j) {
      if (!isalpha(buf[j])) continue;
      s[i] += tolower(buf[j]);
    }
  }
  for (i = 0; i < 3; ++i) {
    for (j = 0; j < 3; ++j) {
      if (j == i) continue;
      for (k = 0; k < 3; ++k) {
        if (k == i || k == j) continue;
        tt.insert(s[i] + s[j] + s[k]);
      }
    }
  }
  scanf("%d", &n);
  while (n--) {
    cin >> buf;
    t.clear();
    for (i = 0; buf[i]; ++i) {
      if (!isalpha(buf[i])) continue;
      t += tolower(buf[i]);
    }
    if (tt.find(t) == tt.end())
      puts("WA");
    else
      puts("ACC");
  }
  return 0;
}
