#include <bits/stdc++.h>
using namespace std;
string init[3];
bool b_used[3];
void cut(string& s) {
  string c = s;
  s.clear();
  for (int i = 0; i < c.size(); ++i) {
    switch (c[i]) {
      case '_':
      case ';':
      case '-':
        continue;
        break;
    }
    s.push_back(tolower(c[i]));
  }
}
bool check(string& s, int j, int n) {
  if (j >= n) {
    if ((b_used[0]) && (b_used[1]) && (b_used[2])) return true;
  }
  bool ret = false;
  for (int i = 0; i < 3; ++i) {
    if ((s.substr(j, init[i].size()) == init[i]) && (!b_used[i])) {
      b_used[i] = true;
      ret |= check(s, j + init[i].size(), n);
      b_used[i] = false;
    }
  }
  return ret;
}
int main() {
  for (int i = 0; i < 3; ++i) {
    cin >> init[i];
    cut(init[i]);
  }
  int n;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    string temp;
    cin >> temp;
    cut(temp);
    bool b_ok = true;
    int j = 0;
    b_used[0] = b_used[1] = b_used[2] = false;
    b_ok = check(temp, 0, temp.size());
    if (b_ok)
      cout << "ACC";
    else
      cout << "WA";
    if (i < n) cout << "\n";
  }
  return 0;
}
