#include <bits/stdc++.h>
using namespace std;
int main() {
  int n = 3;
  int g = 0;
  string ss;
  vector<string> v(3);
  while (n--) {
    cin >> ss;
    for (int i = 0; i < ss.size(); i++) {
      if (isalpha(ss[i]))
        ss[i] = tolower(ss[i]);
      else {
        ss.erase(i, 1);
        i--;
      }
    }
    v[g++] = ss;
  }
  string s1 = v[0], s2 = v[1], s3 = v[2];
  int t;
  cin >> t;
  while (t--) {
    cin >> ss;
    for (int i = 0; i < ss.size(); i++) {
      if (isalpha(ss[i]))
        ss[i] = tolower(ss[i]);
      else {
        ss.erase(i, 1);
        i--;
      }
    }
    if (s1 + s2 + s3 == ss || s1 + s3 + s2 == ss || s2 + s1 + s3 == ss ||
        s2 + s3 + s1 == ss || s3 + s2 + s1 == ss || s3 + s1 + s2 == ss)
      cout << "ACC" << endl;
    else
      cout << "WA" << endl;
  }
}
