#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int t = 1;
  while (t--) {
    string a, b, c;
    cin >> a >> b >> c;
    string x, y, z;
    for (int i = int(0); i < int(a.length()); i++) {
      if (isalpha(a[i])) x += (char)tolower(a[i]);
    }
    for (int i = int(0); i < int(b.length()); i++) {
      if (isalpha(b[i])) y += tolower(b[i]);
    }
    for (int i = int(0); i < int(c.length()); i++) {
      if (isalpha(c[i])) z += tolower(c[i]);
    }
    int n;
    cin >> n;
    while (n--) {
      string s, o;
      cin >> s;
      for (int i = int(0); i < int(s.length()); i++) {
        if (isalpha(s[i])) o += tolower(s[i]);
      }
      if (o == (x + y + z) || o == (y + x + z) || o == (x + z + y) ||
          o == (y + z + x) || o == (z + x + y) || o == (z + y + x))
        cout << "ACC" << endl;
      else
        cout << "WA" << endl;
    }
  }
}
