#include <bits/stdc++.h>
using namespace std;
const int N = 666;
string ch[3], ac[6], a, c;
int l[3], trans[6][3] = {0, 1, 2, 0, 2, 1, 1, 0, 2, 1, 2, 0, 2, 1, 0, 2, 0, 1};
bool check() {
  for (int i = 0; i < 6; i++)
    if (a == ac[i]) return 1;
  return 0;
}
int main() {
  int l, n;
  for (int i = 0; i < 3; i++) {
    cin >> c;
    l = c.length();
    for (int j = 0; j < l; j++)
      if (isalpha(c[j])) ch[i] += toupper(c[j]);
  }
  for (int i = 0; i < 6; i++)
    for (int j = 0; j < 3; j++) ac[i] += ch[trans[i][j]];
  cin >> n;
  while (n--) {
    cin >> c;
    l = c.length();
    a.clear();
    for (int i = 0; i < l; i++)
      if (isalpha(c[i])) a += toupper(c[i]);
    if (check())
      cout << "ACC\n";
    else
      cout << "WA\n";
  }
}
