#include <bits/stdc++.h>
using namespace std;
int main() {
  string a1, b1, c1, a, b, c;
  cin >> a1 >> b1 >> c1;
  int n, i, j;
  cin >> n;
  string s1[n], s[n];
  for (i = 0; a1[i] != 0; i++) {
    if (a1[i] != '-' && a1[i] != ';' && a1[i] != '_') {
      if (a1[i] < 97)
        a.push_back(a1[i] + 32);
      else
        a.push_back(a1[i]);
    }
  }
  for (i = 0; b1[i] != 0; i++) {
    if (b1[i] != '-' && b1[i] != ';' && b1[i] != '_') {
      if (b1[i] < 97)
        b.push_back(b1[i] + 32);
      else
        b.push_back(b1[i]);
    }
  }
  for (i = 0; c1[i] != 0; i++) {
    if (c1[i] != '-' && c1[i] != ';' && c1[i] != '_') {
      if (c1[i] < 97)
        c.push_back(c1[i] + 32);
      else
        c.push_back(c1[i]);
    }
  }
  for (i = 0; i < n; i++) {
    cin >> s1[i];
    for (j = 0; s1[i][j] != 0; j++) {
      if (s1[i][j] != '-' && s1[i][j] != ';' && s1[i][j] != '_') {
        if (s1[i][j] < 97)
          s[i].push_back(s1[i][j] + 32);
        else
          s[i].push_back(s1[i][j]);
      }
    }
  }
  string x1, x2, x3, x4, x5, x6;
  x1 = a + b + c;
  x2 = a + c + b;
  x3 = b + a + c;
  x4 = b + c + a;
  x5 = c + a + b;
  x6 = c + b + a;
  for (i = 0; i < n; i++) {
    if (s[i] == x1 || s[i] == x2 || s[i] == x3 || s[i] == x4 || s[i] == x5 ||
        s[i] == x6)
      cout << "ACC" << endl;
    else
      cout << "WA" << endl;
  }
}
