#include <bits/stdc++.h>
using namespace std;
void lower(string &s) {
  string c;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] != '-' && s[i] != '_' && s[i] != ',' && s[i] != ';')
      c += tolower(s[i]);
  }
  s = c;
}
int main() {
  string a, b, c, sh;
  cin >> a >> b >> c;
  lower(a);
  lower(b);
  lower(c);
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> sh;
    lower(sh);
    puts(a + b + c == sh || a + c + b == sh || b + a + c == sh ||
                 b + c + a == sh || c + a + b == sh || c + b + a == sh
             ? "ACC"
             : "WA");
  }
  return 0;
}
