#include <bits/stdc++.h>
using namespace std;
void fun(int b, int d) {
  int u = 1;
  int v = 0;
  if ((b < 0 && d > 0) || (b > 0 && d < 0)) v = 1;
  b = abs(b);
  d = abs(d);
  if (b < d) {
    swap(b, d);
    u = 0;
  }
  int b1 = b, d1 = d;
  int x = b % d;
  while (x) {
    b = d;
    d = x;
    x = b % d;
  }
  if (u == 0) {
    if (v) d1 *= -1;
    cout << d1 / d << "/" << b1 / d;
  } else {
    if (v) b1 *= -1;
    cout << b1 / d << "/" << d1 / d;
  }
}
int po(int m, int i) {
  int r = 1;
  while (i--) {
    r *= m;
  }
  return r;
}
long long num7(long long x) {
  long long v = 0;
  while (x) {
    if (x % 10 == 7) v++;
    x /= 10;
  }
  return v;
}
long long num4(long long x) {
  long long v = 0;
  while (x) {
    if (x % 10 == 4) v++;
    x /= 10;
  }
  return v;
}
string s[3];
int main() {
  string arr[3];
  getline(cin, arr[0]);
  getline(cin, arr[1]);
  getline(cin, arr[2]);
  for (int i = 0; i < 3; i++) {
    for (unsigned int j = 0; j < arr[i].size(); j++) {
      if (isalpha(arr[i][j])) {
        s[i] += tolower(arr[i][j]);
      }
    }
  }
  string f;
  getline(cin, f);
  int n;
  stringstream y;
  y << f;
  y >> n;
  while (n--) {
    string a, b = "";
    int p[3];
    p[0] = 0, p[1] = 1, p[2] = 2;
    getline(cin, a);
    for (unsigned int i = 0; i < a.size(); i++) {
      if (isalpha(a[i])) {
        b += tolower(a[i]);
      }
    }
    unsigned int ind = 0, u;
    do {
      ind = 0, u = 1;
      for (int i = 0; i < 3; i++) {
        if (ind == b.size()) {
          u = 0;
          break;
        }
        ind = b.find(s[p[i]], ind);
        if (ind < 0 || ind > b.size()) {
          u = 0;
          break;
        } else
          ind += s[p[i]].size();
      }
      if (u) break;
    } while (next_permutation(p, p + 3));
    if (u) {
      if (b.size() == s[0].size() + s[1].size() + s[2].size())
        cout << "ACC" << endl;
      else
        cout << "WA" << endl;
    } else
      cout << "WA" << endl;
  }
  return 0;
}
