#include <bits/stdc++.h>
using namespace std;
bool ok;
int main() {
  string s1, s2, s3, t, sc;
  cin >> t;
  for (int i = 0; i < t.length(); i++)
    if (isalpha(t[i])) s1 += tolower(t[i]);
  cin >> t;
  for (int i = 0; i < t.length(); i++)
    if (isalpha(t[i])) s2 += tolower(t[i]);
  cin >> t;
  for (int i = 0; i < t.length(); i++)
    if (isalpha(t[i])) s3 += tolower(t[i]);
  vector<string> a(6);
  a[0] = s1 + s2 + s3;
  a[1] = s1 + s3 + s2;
  a[2] = s2 + s1 + s3;
  a[3] = s2 + s3 + s1;
  a[4] = s3 + s1 + s2;
  a[5] = s3 + s2 + s1;
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> t;
    sc = "";
    ok = 0;
    for (int i = 0; i < t.length(); i++)
      if (isalpha(t[i])) sc += tolower(t[i]);
    for (int j = 0; j < 6; j++)
      if (a[j] == sc) ok = 1;
    if (!ok)
      cout << "WA\n";
    else
      cout << "ACC\n";
  }
  return 0;
}
