#include <bits/stdc++.h>
using namespace std;
string filter(string a) {
  string x;
  for (int i = 0; i < a.length(); i++) {
    if (a[i] >= 'a' && a[i] <= 'z')
      x = x + a[i];
    else if (a[i] >= 'A' && a[i] <= 'Z') {
      x = x + (char)(a[i] + 32);
    }
  }
  return x;
}
int main() {
  string a, b, c;
  cin >> a >> b >> c;
  a = filter(a);
  b = filter(b);
  c = filter(c);
  vector<string> v(6);
  v[0] = a + b + c;
  v[1] = a + c + b;
  v[2] = b + a + c;
  v[3] = b + c + a;
  v[4] = c + a + b;
  v[5] = c + b + a;
  int n;
  string t;
  cin >> n;
  while (n--) {
    cin >> t;
    t = filter(t);
    int f = 0;
    for (int i = 0; i < 6; i++) {
      if (t.compare(v[i]) == 0) {
        f = 1;
        break;
      }
    }
    if (!f)
      cout << "WA" << endl;
    else
      cout << "ACC" << endl;
  }
  return 0;
}
