#include <bits/stdc++.h>
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
const long double PI = acos(-1);
const int N = 1e5 + 10;
const int MOD = 1e9 + 7;
const int mod1 = 998244353;
const long long INF = 2e18;
string red(string s) {
  string temp = "";
  for (int i = 0; i < s.length(); i++) {
    if (isalpha(s[i])) {
      temp += tolower(s[i]);
    }
  }
  return temp;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  cerr.tie(nullptr);
  {
    map<string, int> mp;
    string x, y, z;
    cin >> x >> y >> z;
    x = red(x);
    y = red(y);
    z = red(z);
    ++mp[x + y + z];
    ++mp[x + z + y];
    ++mp[y + x + z];
    ++mp[y + z + x];
    ++mp[z + x + y];
    ++mp[z + y + x];
    string ss;
    int n;
    cin >> n;
    while (n--) {
      cin >> ss;
      ss = red(ss);
      if (mp[ss]) {
        cout << "ACC"
             << "\n";
      } else {
        cout << "WA"
             << "\n";
      }
    }
  }
  return EXIT_SUCCESS;
}
