#include <bits/stdc++.h>
using namespace std;
int main() {
  string c1, c2, c3, s4, s5, s6, s1, s2, s3;
  char ch;
  int n, i;
  cin >> c1;
  cin >> c2;
  cin >> c3;
  c1.erase(remove(c1.begin(), c1.end(), '_'), c1.end());
  c1.erase(remove(c1.begin(), c1.end(), '-'), c1.end());
  c1.erase(remove(c1.begin(), c1.end(), ';'), c1.end());
  c2.erase(remove(c2.begin(), c2.end(), '_'), c2.end());
  c2.erase(remove(c2.begin(), c2.end(), '-'), c2.end());
  c2.erase(remove(c2.begin(), c2.end(), ';'), c2.end());
  c3.erase(remove(c3.begin(), c3.end(), '_'), c3.end());
  c3.erase(remove(c3.begin(), c3.end(), '-'), c3.end());
  c3.erase(remove(c3.begin(), c3.end(), ';'), c3.end());
  transform(c1.begin(), c1.end(), c1.begin(), ::tolower);
  transform(c2.begin(), c2.end(), c2.begin(), ::tolower);
  transform(c3.begin(), c3.end(), c3.begin(), ::tolower);
  s6 = c1 + c2 + c3;
  s5 = c1 + c3 + c2;
  s4 = c2 + c3 + c1;
  s3 = c2 + c1 + c3;
  s2 = c3 + c1 + c2;
  s1 = c3 + c2 + c1;
  cin >> n;
  while (n--) {
    cin >> c1;
    c1.erase(remove(c1.begin(), c1.end(), '_'), c1.end());
    c1.erase(remove(c1.begin(), c1.end(), '-'), c1.end());
    c1.erase(remove(c1.begin(), c1.end(), ';'), c1.end());
    transform(c1.begin(), c1.end(), c1.begin(), ::tolower);
    if (c1 == s1 || c1 == s2 || c1 == s3 || c1 == s4 || c1 == s5 || c1 == s6) {
      cout << "ACC\n";
    } else {
      cout << "WA\n";
    }
  }
}
