#include <bits/stdc++.h>
using namespace std;
inline char tolower(char a) {
  if (a >= 'A' && a <= 'Z')
    return a - 'A' + 'a';
  else
    return a;
}
inline bool issign(char a) {
  if (a == ';' || a == '_' || a == '-') return true;
  return false;
}
char arr[3][1000], tmp[1000];
bool check(char *tmp, int a, int b, int c) {
  int len = 0;
  for (int i = 0; i < strlen(arr[a]); i++) {
    if (tmp[len++] != arr[a][i]) return false;
  }
  for (int i = 0; i < strlen(arr[b]); i++) {
    if (tmp[len++] != arr[b][i]) return false;
  }
  for (int i = 0; i < strlen(arr[c]); i++) {
    if (tmp[len++] != arr[c][i]) return false;
  }
  return true;
}
int main() {
  for (int j = 0; j < 3; j++) {
    cin >> tmp;
    int len = 0;
    for (int i = 0; i < strlen(tmp); i++) {
      if (!issign(tmp[i])) {
        arr[j][len++] = tolower(tmp[i]);
      }
    }
    arr[j][len] = '\0';
  }
  int N;
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> tmp;
    int len = 0;
    for (int i = 0; i < strlen(tmp); i++) {
      if (!issign(tmp[i])) tmp[len++] = tolower(tmp[i]);
    }
    tmp[len] = '\0';
    if (strlen(tmp) != (strlen(arr[0]) + strlen(arr[1]) + strlen(arr[2])))
      cout << "WA\n";
    else if (check(tmp, 0, 1, 2) || check(tmp, 0, 2, 1) ||
             check(tmp, 1, 0, 2) || check(tmp, 1, 2, 0) ||
             check(tmp, 2, 0, 1) || check(tmp, 2, 1, 0))
      cout << "ACC\n";
    else
      cout << "WA\n";
  }
  return 0;
}
