#include <bits/stdc++.h>
using namespace std;
int i, j, len, a, n;
string s[4], sb, sss[8];
bool der;
int main() {
  for (i = 0; i < 3; ++i) {
    cin >> s[i];
    for (j = 0; j < s[i].length(); ++j) {
      a = s[i][j];
      if (((a < 65) || ((a > 90) && (a < 97))) || (a > 122)) {
        s[i].erase(j, 1);
        --j;
      } else if (a < 91) {
        s[i][j] = a + 32;
      }
    }
  }
  sss[0] = s[0] + s[1] + s[2];
  sss[1] = s[0] + s[2] + s[1];
  sss[2] = s[1] + s[0] + s[2];
  sss[3] = s[1] + s[2] + s[0];
  sss[4] = s[2] + s[0] + s[1];
  sss[5] = s[2] + s[1] + s[0];
  cin >> n;
  for (i = 0; i < n; ++i) {
    cin >> sb;
    for (j = 0; j < sb.length(); ++j) {
      a = sb[j];
      if (((a < 65) || ((a > 90) && (a < 97))) || (a > 122)) {
        sb.erase(j, 1);
        --j;
      } else if (a < 91) {
        sb[j] = a + 32;
      }
    }
    for (j = 0; j < 6; ++j) {
      if (sb == sss[j]) {
        der = true;
        break;
      }
    }
    if (der == true) {
      cout << "ACC"
           << "\n";
      der = false;
    } else {
      cout << "WA"
           << "\n";
    }
  }
  return 0;
}
