#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e9;
const long long N = 1e6 + 1;
const long long mod = 1e8 + 0;
const long double eps = 1E-7;
int test;
string s, t;
string a[7], b[7];
int main() {
  for (int i = 1; i <= 3; i++) {
    s = "";
    cin >> t;
    for (int j = 0; j < t.size(); j++) {
      if (t[j] != '-' and t[j] != ';' and t[j] != '_') {
        s += tolower(t[j]);
      }
    }
    a[i] = s;
  }
  b[1] = a[1] + a[2] + a[3];
  b[2] = a[1] + a[3] + a[2];
  b[3] = a[2] + a[1] + a[3];
  b[4] = a[2] + a[3] + a[1];
  b[5] = a[3] + a[1] + a[2];
  b[6] = a[3] + a[2] + a[1];
  cin >> test;
  while (test--) {
    s = "";
    bool flag = false;
    cin >> t;
    for (int i = 0; i < t.size(); i++) {
      if (t[i] != '-' and t[i] != ';' and t[i] != '_') {
        s += tolower(t[i]);
      }
    }
    for (int i = 1; i <= 6; i++) {
      if (b[i] == s) flag = true;
    }
    if (!flag) {
      cout << "WA" << endl;
    } else {
      cout << "ACC" << endl;
    }
  }
}
