#include <bits/stdc++.h>
using namespace std;
string erase(string s) {
  string x;
  for (int c = 0; c < s.size(); c++) {
    int k = 0;
    if (s[c] == ';' or s[c] == '_' or s[c] == '-')
      k++;
    else {
      if (s[c] >= 97) s[c] -= 32;
      x.push_back(s[c]);
    }
  }
  return x;
}
int main() {
  string x, y, z;
  cin >> x >> y >> z;
  x = erase(x);
  y = erase(y);
  z = erase(z);
  int n;
  cin >> n;
  string res;
  for (int c = 0; c < n; c++) {
    cin >> res;
    res = erase(res);
    if (res == x + y + z || res == x + z + y || res == y + x + z ||
        res == y + z + x || res == z + y + x || res == z + x + y)
      cout << "ACC" << endl;
    else
      cout << "WA" << endl;
  }
  return 0;
}
