#include <bits/stdc++.h>
using namespace std;
string a, b, c, s[6], x, s1;
int n;
int main() {
  cin >> a >> b >> c;
  for (int i = 0; i < a.size(); i++) {
    if (a[i] == '_' || a[i] == '-' || a[i] == ';') {
      a.erase(i, 1);
      i--;
      continue;
    }
    a[i] = tolower(a[i]);
  }
  for (int i = 0; i < b.size(); i++) {
    if (b[i] == '_' || b[i] == '-' || b[i] == ';') {
      b.erase(i, 1);
      i--;
      continue;
    }
    b[i] = tolower(b[i]);
  }
  for (int i = 0; i < c.size(); i++) {
    if (c[i] == '_' || c[i] == '-' || c[i] == ';') {
      c.erase(i, 1);
      i--;
      continue;
    }
    c[i] = tolower(c[i]);
  }
  s[0] = a + b + c;
  s[1] = a + c + b;
  s[2] = b + a + c;
  s[3] = b + c + a;
  s[4] = c + a + b;
  s[5] = c + b + a;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> x;
    int f = 0;
    for (int j = 0; j < x.size(); j++) {
      if (x[j] == '_' || x[j] == '-' || x[j] == ';') {
        x.erase(j, 1);
        j--;
        continue;
      }
      x[j] = tolower(x[j]);
    }
    for (int j = 0; j < 6; j++)
      if (s[j] == x) {
        f = 1;
        break;
      }
    if (f == 1)
      cout << "ACC" << endl;
    else
      cout << "WA" << endl;
  }
  return 0;
}
