#include <bits/stdc++.h>
using namespace std;
const long long int N = 4e5 + 5;
vector<int> v;
int main() {
  ios_base ::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long n, i = 0, j, cnt1 = 0, ans = 1, sum = 1, k, maxi, cnt2 = 0;
  string a, b, c, x, y, z;
  char yo;
  cin >> a >> b >> c;
  cin >> n;
  map<string, int> m;
  for (j = 0; j < a.length(); j++) {
    if (a[j] == '-' || a[j] == '_' || a[j] == ';') continue;
    yo = tolower(a[j]);
    x += yo;
  }
  for (j = 0; j < b.length(); j++) {
    if (b[j] == '-' || b[j] == '_' || b[j] == ';') continue;
    yo = tolower(b[j]);
    y += yo;
  }
  for (j = 0; j < c.length(); j++) {
    if (c[j] == '-' || c[j] == '_' || c[j] == ';') continue;
    yo = tolower(c[j]);
    z += yo;
  }
  m[x + y + z]++;
  m[x + z + y]++;
  m[y + x + z]++;
  m[y + z + x]++;
  m[z + y + x]++;
  m[z + x + y]++;
  while (n--) {
    string p = "";
    cin >> x;
    for (j = 0; j < x.length(); j++) {
      if (x[j] == '-' || x[j] == '_' || x[j] == ';') continue;
      yo = tolower(x[j]);
      p += yo;
    }
    if (m[p])
      cout << "ACC" << endl;
    else
      cout << "WA" << endl;
  }
  return 0;
}
