#include <bits/stdc++.h>
using namespace std;
string process(string s) {
  string temp;
  for (int i = 0; i < s.length(); i++) {
    if (s[i] != ';' && s[i] != '-' && s[i] != '_') {
      if (s[i] >= 65 && s[i] <= 90) {
        temp += char(s[i] + 32);
      } else {
        temp += s[i];
      }
    }
  }
  return temp;
}
bool check(string test, vector<string> &example) {
  int i = 0;
  int j = 0;
  int n = test.length();
  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 3; j++) {
      for (int k = 0; k < 3; k++) {
        if ((i == j) || (k == i || k == j)) {
          continue;
        }
        string temp = example[i] + example[j] + example[k];
        if (temp == test) {
          return true;
        }
      }
    }
  }
  return false;
}
int main() {
  vector<string> example(3);
  cin >> example[0] >> example[1] >> example[2];
  for (int i = 0; i < 3; i++) {
    example[i] = process(example[i]);
  }
  sort(example.begin(), example.end());
  int n;
  cin >> n;
  vector<string> arr(n);
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
    string temp = process(arr[i]);
    if (check(temp, example)) {
      cout << "ACC" << endl;
    } else {
      cout << "WA" << endl;
    }
  }
  return 0;
}
