human
Here the teacher said: given the following:
After the contest in comparing numbers, Shapur's teacher found out that he is a real genius and that no one could possibly do the calculations faster than him even using a super computer!

Some days before the contest, the teacher took a very simple-looking exam and all his n students took part in the exam. The teacher gave them 3 strings and asked them to concatenate them. Concatenating strings means to put them in some arbitrary order one after the other. For example from concatenating Alireza and Amir we can get to AlirezaAmir or AmirAlireza depending on the order of concatenation.

Unfortunately enough, the teacher forgot to ask students to concatenate their strings in a pre-defined order so each student did it the way he/she liked.

Now the teacher knows that Shapur is such a fast-calculating genius boy and asks him to correct the students' papers.

Shapur is not good at doing such a time-taking task. He rather likes to finish up with it as soon as possible and take his time to solve 3-SAT in polynomial time. Moreover, the teacher has given some advice that Shapur has to follow. Here's what the teacher said: 

  * As I expect you know, the strings I gave to my students (including you) contained only lowercase and uppercase Persian Mikhi-Script letters. These letters are too much like Latin letters, so to make your task much harder I converted all the initial strings and all of the students' answers to Latin. 
  * As latin alphabet has much less characters than Mikhi-Script, I added three odd-looking characters to the answers, these include "-", ";" and "_". These characters are my own invention of course! And I call them Signs. 
  * The length of all initial strings was less than or equal to 100 and the lengths of my students' answers are less than or equal to 600
  * My son, not all students are genius as you are. It is quite possible that they make minor mistakes changing case of some characters. For example they may write ALiReZaAmIR instead of AlirezaAmir. Don't be picky and ignore these mistakes. 
 ...
assistant
#Here the teacher said: 
.

from sys import stdin, stdout
class Solve:
  def string(self):
    tmp = ''
    s = stdin.readline().lower()
    for i in range(len(s)-1):
      if s[i] not in [';', '-', '_']:
        tmp += s[i]
    return tmp
  def __init__(self):
    R = stdin.readline
    W = stdout.write
    check = {}
    ans = []
    a = self.string()
    b = self.string()
    c = self.string()
    check[a+b+c] = check[a+c+b] = check[b+a+c] = check[b+c+a] = check[c+a+b] = check[c+b+a] = True
    n = int(input())
    for i in range(n):
      s = R().lower()
      tmp = ''
      flg = 0
      for j in range(len(s)-1):
        if s[j] not in [';', '-', '_']:
          tmp += s[j]
        if tmp in check:
          flg += 1
          tmp = ''
      ans.append('ACC' if (tmp == '' and flg == 1) else 'WA')
    W('\n'.join(ans))
def main():
  s = Solve()
main()