#include <bits/stdc++.h>
using namespace std;
string ans[9];
int main() {
  string A[3], b;
  string t;
  for (int i = 0; i < 3; i++) {
    cin >> b;
    t = "";
    for (int j = 0; j < b.size(); j++) {
      if (b[j] == ';' || b[j] == '_' || b[j] == '-') continue;
      if (b[j] <= 'Z' && b[j] >= 'A') b[j] -= 'A' - 'a';
      t += b[j];
    }
    A[i] = t;
  }
  for (int i = 0; i < 3; i++) {
    ans[i * 2] = A[i] + A[(i + 1) % 3] + A[(i + 2) % 3];
    ans[i * 2 + 1] = A[i] + A[(i + 2) % 3] + A[(i + 1) % 3];
  }
  int T;
  cin >> T;
  while (T--) {
    cin >> b;
    t = "";
    for (int j = 0; j < b.size(); j++) {
      if (b[j] == ';' || b[j] == '_' || b[j] == '-') continue;
      if (b[j] <= 'Z' && b[j] >= 'A') b[j] -= 'A' - 'a';
      t += b[j];
    }
    int j;
    for (j = 0; j < 6; j++) {
      if (t == ans[j]) break;
    }
    if (j == 6)
      cout << "WA" << endl;
    else
      cout << "ACC" << endl;
  }
  return 0;
}
