#include <bits/stdc++.h>
using namespace std;
string s1, s2, s3, second[6];
bool check(string s) {
  for (int i = 0; i < 6; i++) {
    string sss = second[i];
    int k = 0;
    if (sss == s) return true;
  }
  return false;
}
string analyse(string s) {
  string sx = "";
  for (int i = 0; i < s.size(); i++) {
    if ((s[i] >= 'a' && s[i] <= 'z')) sx += s[i];
    if ((s[i] >= 'A' && s[i] <= 'Z')) sx += s[i] - 'A' + 'a';
  }
  return sx;
}
int main() {
  string s;
  cin >> s1 >> s2 >> s3;
  s1 = analyse(s1);
  s2 = analyse(s2);
  s3 = analyse(s3);
  second[0] = s1 + s2 + s3;
  second[1] = s1 + s3 + s2;
  second[2] = s2 + s1 + s3;
  second[3] = s2 + s3 + s1;
  second[4] = s3 + s2 + s1;
  second[5] = s3 + s1 + s2;
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> s;
    if (check(analyse(s))) {
      cout << "ACC" << endl;
    } else
      cout << "WA" << endl;
  }
  return 0;
}
