#include <bits/stdc++.h>
using namespace std;
string change(string a) {
  int i;
  string x;
  for (i = 0; i < a.size(); i++) {
    if (a[i] == '-' || a[i] == ';' || a[i] == '_') {
      continue;
    } else
      x += tolower(a[i]);
  }
  return x;
}
int main() {
  string a[3];
  string out[6];
  string temp;
  int n;
  int t;
  int i;
  int indx;
  int flag;
  cin >> a[0];
  a[0] = change(a[0]);
  cin >> a[1];
  a[1] = change(a[1]);
  cin >> a[2];
  a[2] = change(a[2]);
  out[0] = a[0] + a[1] + a[2];
  out[1] = a[0] + a[2] + a[1];
  out[2] = a[1] + a[2] + a[0];
  out[3] = a[1] + a[0] + a[2];
  out[4] = a[2] + a[1] + a[0];
  out[5] = a[2] + a[0] + a[1];
  cin >> t;
  indx = 0;
  while (t--) {
    cin >> temp;
    temp = change(temp);
    indx = 0;
    flag = 0;
    for (indx = 0; indx < 3; indx++) {
      if (temp.find(a[indx]) > temp.size()) {
        cout << "WA" << endl;
        flag = 1;
        break;
      }
    }
    if (flag == 1) {
      continue;
    }
    for (indx = 0; indx < 6; indx++) {
      if (out[indx] == temp) {
        cout << "ACC" << endl;
        flag = 1;
        break;
      }
    }
    if (flag == 0) {
      cout << "WA" << endl;
    }
  }
  return 0;
}
