#include <bits/stdc++.h>
using namespace std;
int main() {
  string a, b, c;
  string a1 = "", b1 = "", c1 = "";
  cin >> a >> b >> c;
  for (int i = 0; i < a.size(); i++) {
    if (a[i] != ';' && a[i] != '-' && a[i] != '_') {
      if (a[i] >= 'a' && a[i] <= 'z') a[i] = a[i] - 32;
      a1 += a[i];
    }
  }
  for (int i = 0; i < b.size(); i++) {
    if (b[i] != ';' && b[i] != '-' && b[i] != '_') {
      if (b[i] >= 'a' && b[i] <= 'z') b[i] = b[i] - 32;
      b1 += b[i];
    }
  }
  for (int i = 0; i < c.size(); i++) {
    if (c[i] != ';' && c[i] != '-' && c[i] != '_') {
      if (c[i] >= 'a' && c[i] <= 'z') c[i] = c[i] - 32;
      c1 += c[i];
    }
  }
  int n;
  cin >> n;
  string* m = new string[n];
  string* m1 = new string[n];
  for (int i = 0; i < n; i++) {
    cin >> m[i];
  }
  for (int j = 0; j < n; j++) {
    for (int i = 0; i < m[j].size(); i++) {
      if (m[j][i] != ';' && m[j][i] != '-' && m[j][i] != '_') {
        if (m[j][i] >= 'a' && m[j][i] <= 'z') m[j][i] = m[j][i] - 32;
        m1[j] += m[j][i];
      }
    }
  }
  string* s = new string[6];
  s[0] = a1 + b1 + c1;
  s[1] = a1 + c1 + b1;
  s[2] = b1 + a1 + c1;
  s[3] = b1 + c1 + a1;
  s[4] = c1 + a1 + b1;
  s[5] = c1 + b1 + a1;
  bool r;
  for (int i = 0; i < n; i++) {
    r = false;
    for (int j = 0; j < 6 && !r; j++)
      if (m1[i] == s[j]) r = true;
    if (r)
      cout << "ACC" << endl;
    else
      cout << "WA" << endl;
  }
  return 0;
}
