#include <bits/stdc++.h>
using namespace std;
char in[700];
string inans;
string s[4] = {"", "", ""};
int len;
bool acc = false;
string ans[7];
int n;
int main() {
  for (int i = 0; i < 3; i++) {
    scanf("%s", in);
    len = strlen(in);
    for (int j = 0; j < len; j++) {
      if (in[j] >= 'A' && in[j] <= 'Z')
        s[i] += (char)(in[j] + 32);
      else if (in[j] >= 'a' && in[j] <= 'z')
        s[i] += in[j];
    }
  }
  ans[0] = s[0] + s[1] + s[2];
  ans[1] = s[0] + s[2] + s[1];
  ans[2] = s[1] + s[0] + s[2];
  ans[3] = s[1] + s[2] + s[0];
  ans[4] = s[2] + s[0] + s[1];
  ans[5] = s[2] + s[1] + s[0];
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    inans = "";
    acc = false;
    scanf("%s", in);
    len = strlen(in);
    for (int j = 0; j < len; j++) {
      if (in[j] >= 'A' && in[j] <= 'Z')
        inans += (char)(in[j] + 32);
      else if (in[j] >= 'a' && in[j] <= 'z')
        inans += in[j];
    }
    for (int j = 0; j < 6; j++) {
      if (inans == ans[j]) {
        acc = true;
        break;
      }
    }
    if (acc)
      printf("ACC\n");
    else
      printf("WA\n");
  }
  return 0;
}
