#include <bits/stdc++.h>
using namespace std;
int main() {
  string m[3];
  for (int i = 0; i < 3; i++) {
    string k;
    cin >> k;
    string h = "";
    for (int j = 0; j < k.length(); j++) {
      if (k[j] == '-' || k[j] == ';' || k[j] == '_') {
        continue;
      }
      if (k[j] >= 65 && k[j] <= 90) {
        k[j] += 32;
      }
      h += k[j];
    }
    m[i] = h;
  }
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    string k;
    cin >> k;
    string h = "", g = "";
    bool r[3] = {0, 0, 0};
    bool b[3] = {0, 0, 0};
    for (int j = 0; j < k.length(); j++) {
      if (k[j] == '-' || k[j] == ';' || k[j] == '_') {
        continue;
      }
      if (k[j] >= 65 && k[j] <= 90) {
        k[j] += 32;
      }
      h += k[j];
      for (int s = 0; s < 3; s++) {
        if (h == m[s] && r[s] == 0) {
          r[s] = 1;
          h = "";
          break;
        }
      }
    }
    h = "";
    for (int j = k.length() - 1; j >= 0; j--) {
      if (k[j] == '-' || k[j] == ';' || k[j] == '_') {
        continue;
      }
      if (k[j] >= 65 && k[j] <= 90) {
        k[j] += 32;
      }
      h += k[j];
      for (int s = 0; s < 3; s++) {
        if (h == m[s] && b[s] == 0) {
          b[s] = 1;
          h = "";
          break;
        }
      }
    }
    if (r[0] && r[1] && r[2] || (b[0] && b[1] && b[2])) {
      cout << "ACC";
    } else {
      cout << "WA";
    }
    cout << endl;
  }
}
