#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  string s1, s2, s3;
  cin >> s1 >> s2 >> s3;
  string ss1, ss2, ss3;
  for (int i = 0; i < s1.size(); ++i) {
    if (s1[i] == '-' || s1[i] == '_' || s1[i] == ';') continue;
    ss1 += tolower(s1[i]);
  }
  for (int i = 0; i < s2.size(); ++i) {
    if (s2[i] == '-' || s2[i] == '_' || s2[i] == ';') continue;
    ss2 += tolower(s2[i]);
  }
  for (int i = 0; i < s3.size(); ++i) {
    if (s3[i] == '-' || s3[i] == '_' || s3[i] == ';') continue;
    ss3 += tolower(s3[i]);
  }
  string c1 = ss1 + ss2 + ss3, c2 = ss1 + ss3 + ss2, c3 = ss2 + ss1 + ss3,
         c4 = ss2 + ss3 + ss1, c5 = ss3 + ss2 + ss1, c6 = ss3 + ss1 + ss2;
  int t;
  cin >> t;
  while (t--) {
    string ss;
    string s;
    cin >> s;
    ;
    for (int i = 0; i < s.size(); ++i) {
      if (s[i] == '-' || s[i] == '_' || s[i] == ';') continue;
      ss += tolower(s[i]);
    }
    if (ss == c1 || ss == c2 || ss == c3 || ss == c4 || ss == c5 || ss == c6) {
      cout << "ACC"
           << "\n";
    } else {
      cout << "WA"
           << "\n";
    }
  }
  return 0;
}
