#include <bits/stdc++.h>
std::string read_string() {
  std::string str, res = "";
  std::cin >> str;
  for (size_t i = 0; i < str.size(); i++) {
    char c = str[i];
    if (isalpha(c)) {
      if (isupper(c)) c = tolower(c);
      res.push_back(c);
    }
  }
  return res;
}
int main() {
  std::string s1 = read_string(), s2 = read_string(), s3 = read_string();
  std::string ans;
  int n;
  std::cin >> n;
  std::string s123 = s1 + s2 + s3;
  std::string s132 = s1 + s3 + s2;
  std::string s213 = s2 + s1 + s3;
  std::string s231 = s2 + s3 + s1;
  std::string s312 = s3 + s1 + s2;
  std::string s321 = s3 + s2 + s1;
  for (int i = 0; i < n; i++) {
    ans = read_string();
    if (ans == s123)
      std::cout << "ACC\n";
    else if (ans == s132)
      std::cout << "ACC\n";
    else if (ans == s213)
      std::cout << "ACC\n";
    else if (ans == s231)
      std::cout << "ACC\n";
    else if (ans == s312)
      std::cout << "ACC\n";
    else if (ans == s321)
      std::cout << "ACC\n";
    else
      std::cout << "WA\n";
  }
  return 0;
}
