#include <bits/stdc++.h>
using namespace std;
int main() {
  string arr[3];
  for (int i = 0; i < 3; i++) {
    cin >> arr[i];
    for (int j = 0; j < arr[i].size(); j++)
      if (arr[i][j] == ';' || arr[i][j] == '-' || arr[i][j] == '_') {
        arr[i].erase(j, 1);
        j--;
      }
    for (int j = 0; j < arr[i].size(); j++)
      if (arr[i][j] >= 'A' && arr[i][j] <= 'Z') arr[i][j] += 32;
  }
  string s1 = arr[0] + arr[1] + arr[2], s2 = arr[0] + arr[2] + arr[1],
         s3 = arr[1] + arr[0] + arr[2], s4 = arr[1] + arr[2] + arr[0],
         s5 = arr[2] + arr[0] + arr[1], s6 = arr[2] + arr[1] + arr[0];
  string s;
  int n;
  cin >> n;
  while (n--) {
    cin >> s;
    for (int i = 0; i < s.size(); i++) {
      if (s[i] == ';' || s[i] == '-' || s[i] == '_') {
        s.erase(i, 1);
        i--;
      }
      if (s[i] >= 'A' && s[i] <= 'Z') s[i] += 32;
    }
    if (s == s1 || s == s2 || s == s3 || s == s4 || s == s5 || s == s6)
      cout << "ACC" << endl;
    else
      cout << "WA" << endl;
  }
  return 0;
}
