#include <bits/stdc++.h>
using namespace std;
bool check(string all, string ans) { return all.size() == ans.size(); }
bool checkChar(string all, string ans) {
  vector<char> v1, v2;
  for (int i = 0; i < all.size(); i++) v1.push_back(all[i]);
  for (int i = 0; i < ans.size(); i++) v2.push_back(ans[i]);
  sort(v1.begin(), v1.end());
  sort(v2.begin(), v2.end());
  for (int i = 0; i < v1.size(); i++) {
    if (v1[i] != v2[i]) {
      return false;
      break;
    }
  }
  return true;
}
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  string q, s, all;
  int n;
  vector<string> v;
  for (int i = 0; i < 3; i++) {
    string New;
    cin >> q;
    for (int k = 0; k < q.size(); k++) {
      if (isalpha(q[k])) New += tolower(q[k]);
    }
    all += New;
    v.push_back(New);
  }
  cin >> n;
  for (int i = 0; i < n; i++) {
    string NewS;
    cin >> s;
    for (int k = 0; k < s.size(); k++) {
      if (isalpha(s[k])) NewS += tolower(s[k]);
    }
    vector<int> pos;
    for (int m = 0; m < 3; m++) {
      size_t found = NewS.find(v[m]);
      if (found != string::npos) {
        pos.push_back(found);
      } else
        pos.push_back(-1);
    }
    sort(pos.begin(), pos.end());
    if (pos.front() == -1 || pos[0] != 0) {
      cout << "WA" << endl;
    } else {
      if (check(all, NewS) && checkChar(all, NewS))
        cout << "ACC" << endl;
      else
        cout << "WA" << endl;
    }
  }
  return 0;
}
