#include <bits/stdc++.h>
using namespace std;
string str1;
string str2;
string str3;
string str4;
void make_size() {
  string tmp;
  tmp.clear();
  int i, len, j;
  len = str1.size();
  for (i = 0, j = 0; i < len; i++) {
    if (isalpha(str1[i])) {
      str1[i] = tolower(str1[i]);
      tmp += str1[i];
    }
  }
  str1.clear();
  str1 = tmp;
  len = str2.size();
  tmp.clear();
  for (i = 0, j = 0; i < len; i++) {
    if (isalpha(str2[i])) {
      str2[i] = tolower(str2[i]);
      tmp += str2[i];
    }
  }
  str2.clear();
  str2 = tmp;
  len = str3.size();
  tmp.clear();
  for (i = 0, j = 0; i < len; i++) {
    if (isalpha(str3[i])) {
      str3[i] = tolower(str3[i]);
      tmp += str3[i];
    }
  }
  str3.clear();
  str3 = tmp;
}
int main(void) {
  int n, i, j, len;
  string chk;
  while (cin >> str1 >> str2 >> str3) {
    make_size();
    map<string, int> M;
    string comb;
    comb.clear();
    comb += str1;
    comb += str2;
    comb += str3;
    M[comb] = 1;
    comb.clear();
    comb += str1;
    comb += str3;
    comb += str2;
    M[comb] = 1;
    comb.clear();
    comb += str2;
    comb += str1;
    comb += str3;
    M[comb] = 1;
    comb.clear();
    comb += str2;
    comb += str3;
    comb += str1;
    M[comb] = 1;
    comb.clear();
    comb += str3;
    comb += str1;
    comb += str2;
    M[comb] = 1;
    comb.clear();
    comb += str3;
    comb += str2;
    comb += str1;
    M[comb] = 1;
    scanf("%d", &n);
    int count;
    for (i = 0, count = 0; i < n; i++, count = 0) {
      cin >> str4;
      string tmp;
      tmp.clear();
      for (j = 0; j < str4.size(); j++) {
        if (isalpha(str4[j])) {
          str4[j] = tolower(str4[j]);
          tmp += str4[j];
        }
      }
      if (M[tmp])
        printf("ACC\n");
      else
        puts("WA");
    }
  }
}
