#include <bits/stdc++.h>
using namespace std;
int main() {
  char c[3][200];
  char temp[1000];
  int n;
  for (int i = 0; i < 3; i++) {
    cin.getline(temp, 1000);
    int k = 0;
    for (int j = 0; j < strlen(temp); j++) {
      if (temp[j] >= 'A' && temp[j] <= 'Z') {
        c[i][k] = temp[j] + 32;
        k++;
      } else {
        if (temp[j] >= 'a' && temp[j] <= 'z') {
          c[i][k] = temp[j];
          k++;
        }
      }
    }
    c[i][k] = '\0';
  }
  cin >> n;
  int *ms = new int[n];
  for (int i = 0; i < n; i++) ms[i] = 0;
  char tm[1000];
  string otv[6];
  otv[0] = (string)c[0] + (string)c[1] + (string)c[2];
  otv[1] = (string)c[0] + (string)c[2] + (string)c[1];
  otv[2] = (string)c[1] + (string)c[0] + (string)c[2];
  otv[3] = (string)c[1] + (string)c[2] + (string)c[0];
  otv[4] = (string)c[2] + (string)c[0] + (string)c[1];
  otv[5] = (string)c[2] + (string)c[1] + (string)c[0];
  for (int i = 0; i < n; i++) {
    cin >> temp;
    int k = 0;
    for (int j = 0; j < strlen(temp); j++) {
      if (temp[j] >= 'A' && temp[j] <= 'Z') {
        tm[k] = temp[j] + 32;
        k++;
      } else {
        if (temp[j] >= 'a' && temp[j] <= 'z') {
          tm[k] = temp[j];
          k++;
        }
      }
    }
    tm[k] = '\0';
    string ksd = (string)tm;
    for (int l = 0; l < 6; l++) {
      if (ksd == otv[l]) {
        ms[i] = 1;
        break;
      }
    }
  }
  for (int i = 0; i < n; i++) {
    if (ms[i] == 1)
      cout << "ACC\n";
    else
      cout << "WA\n";
  }
  return 0;
}
