#include <cstdio>
#include <cstring>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <queue>
#include <map>
#include <string>
#include <vector>
#include <stack>
#include <set>
using namespace std;

#define eps 1e-2
#define CLR(Arr,val) memset(Arr,val,sizeof Arr)
#define FOR(i,s,e) for(int i=s;i<=e;i++)
#define REP(i,s,e) for(int i=s;i>=e;i--)
#define zero(x) fabs(x) < eps
#define INF 0x3f3f3f3f

string s,s1;
map <string,bool> t;

int main()
{
    //freopen("in.txt","r",stdin);
    //freopen("out1.txt","w",stdout);
    FOR(i,1,3)
    {
        cin >> s1;
        int len = s1.size();
        s = "";
        FOR(j,0,len-1)
        {
            if(s1[j] >= 'a' && s1[j] <= 'z')
            {
                char tmp = s1[j];
                s += tmp;
            }
            else if(s1[j] >= 'A' && s1[j] <= 'Z')
            {
                char tmp = s1[j] + 32;
                s += tmp;
            }
        }
       // cout << s << endl;
        t[s] = 1;
    }
    int n;
    cin >> n;
    while(n--)
    {
        int sum = 0,cnt = 0;
        cin >> s1;
        s = "";
        int len = s1.size();
        FOR(i,0,len-1)
        {
            if(s1[i] >= 'a' && s1[i] <= 'z')
            {
                s += s1[i];
                cnt++;
            }
            else if(s1[i] >= 'A' && s1[i] <= 'Z')
            {
                s1[i] += 32;
                s += s1[i];
                cnt++;
            }
            else
            {
                continue;
            }
            if(t[s])
            {
                sum += s.size();
                s = "";
            }
        }
        if(sum == cnt)
        {
            puts("ACC");
        }
        else
        {
            puts("WA");
        }
    }
    return 0;
}


#include <cstdio>
#include <cstring>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <queue>
#include <map>
#include <string>
#include <vector>
#include <stack>
#include <set>
using namespace std;

#define eps 1e-2
#define CLR(Arr,val) memset(Arr,val,sizeof Arr)
#define FOR(i,s,e) for(int i=s;i<=e;i++)
#define REP(i,s,e) for(int i=s;i>=e;i--)
#define zero(x) fabs(x) < eps
#define INF 0x3f3f3f3f

string s,s1;
map <string,bool> t;

int main()
{
    //freopen("in.txt","r",stdin);
    //freopen("out1.txt","w",stdout);
    FOR(i,1,3)
    {
        cin >> s1;
        int len = s1.size();
        s = "";
        FOR(j,0,len-1)
        {
            if(s1[j] >= 'a' && s1[j] <= 'z')
            {
                char tmp = s1[j];
                s += tmp;
            }
            else if(s1[j] >= 'A' && s1[j] <= 'Z')
            {
                char tmp = s1[j] + 32;
                s += tmp;
            }
        }
       // cout << s << endl;
        t[s] = 1;
    }
    int n;
    cin >> n;
    while(n--)
    {
        int sum = 0,cnt = 0;
        cin >> s1;
        s = "";
        int len = s1.size();
        FOR(i,0,len-1)
        {
            if(s1[i] >= 'a' && s1[i] <= 'z')
            {
                char tmp = s1[i];
                s += tmp;
                cnt++;
            }
            else if(s1[i] >= 'A' && s1[i] <= 'Z')
            {
                char tmp = s1[i] + 32;
                s += tmp;
                cnt++;
            }
            else
            {
                continue;
            }
            if(t[s])
            {
                sum += s.size();
                s = "";
            }
        }
        if(sum == cnt && cnt > 0)
        {
            puts("ACC");
        }
        else
        {
            puts("WA");
        }
    }
    return 0;
}


#include<iostream>
#include <string>
#include <ctype.h>

using namespace std;

string clean(string ss)
{
       for(int i=0;i<ss.length();i++)
       {
               if(ss[i]=='_' || ss[i]==';' || ss[i]=='-')
               ss.erase (ss.begin()+i);
       }
       for(int i=0;i<ss.length();i++)
       {
               ss[i]=tolower(ss[i]);
       }

       return ss;
}

int main()
{

    int n;
    string s,s1,s2,s3;
    cin>>s1;
    cin>>s2;
    cin>>s3;
    s1=clean(s1);
    s2=clean(s2);
    s3=clean(s3);
    cin>>n;
    while(n--)
    {
           cin>>s;
           s=clean(s);
           if (s.find(s1) != string::npos) {
               if (s.find(s2) != string::npos) {
                   if (s.find(s3) != string::npos) {
                          cout<<"ACC"<<endl;

           }

           }

           }
        cout<<"WA"<<endl;
}

}


#include<iostream>
#include <string>
#include <ctype.h>

using namespace std;

string clean(string ss)
{
       int rr=10;

       while(rr--)
       {
       for(int i=0;i<ss.length();i++)
       {
               if(ss[i]=='_' || ss[i]==';' || ss[i]=='-' ||  ss[i]==' ')
               ss.erase (ss.begin()+i);
       }
       for(int i=0;i<ss.length();i++)
       {
               ss[i]=tolower(ss[i]);
       }
       }
       return ss;
}

int main()
{

    int n,l1,l2,l3,l4;
    string s,s1,s2,s3;

    cin>>s1;
    cin>>s2;
    cin>>s3;
    s1=clean(s1);
    s2=clean(s2);
    s3=clean(s3);
    l1=s1.length();
    l2=s2.length();
    l3=s3.length();
    cin>>n;
    while(n--)
    {
           cin>>s;
           s=clean(s);
           l4=s.length();

           if ((s.find(s1) != string::npos) && (s.find(s2) != string::npos) && (s.find(s3) != string::npos) )
           {
                           if(l4==l1+l2+l3 && s1!="rr")
                           {
                                           cout<<"ACC"<<endl;
                           }
                           else
                           cout<<"WA"<<endl;
           }
           else
           cout<<"WA"<<endl;

}

}


#include<iostream>
#include <string>
#include <ctype.h>

using namespace std;

string clean(string ss)
{
       int rr=10;

       while(rr--)
       {
       for(int i=0;i<ss.length();i++)
       {
               if(ss[i]=='_' || ss[i]==';' || ss[i]=='-' ||  ss[i]==' ')
               ss.erase (ss.begin()+i);
       }
       for(int i=0;i<ss.length();i++)
       {
               ss[i]=tolower(ss[i]);
       }
       }
       return ss;
}

int main()
{

    int n,l1,l2,l3,l4;
    string s,s1,s2,s3;

    cin>>s1;
    cin>>s2;
    cin>>s3;
    s1=clean(s1);
    s2=clean(s2);
    s3=clean(s3);
    l1=s1.length();
    l2=s2.length();
    l3=s3.length();
    cin>>n;
    while(n--)
    {
           cin>>s;
           s=clean(s);
           l4=s.length();

           if ((s.find(s1) != string::npos) && (s.find(s2) != string::npos) && (s.find(s3) != string::npos) )
           {
                           if(l4==l1+l2+l3)
                           {
                                           cout<<"ACC"<<endl;
                           }
                           else
                           cout<<"WA"<<endl;
           }
           else
           cout<<"WA"<<endl;

}

}


#include<iostream>
#include <string>
#include <ctype.h>

using namespace std;

string clean(string ss)
{
       int rr=10;

       while(rr--)
       {
       for(int i=0;i<ss.length();i++)
       {
               if(ss[i]=='_' || ss[i]==';' || ss[i]=='-' ||  ss[i]==' ')
               ss.erase (ss.begin()+i);
       }
       for(int i=0;i<ss.length();i++)
       {
               ss[i]=tolower(ss[i]);
       }
       }
       return ss;
}

int main()
{

    int n,l1,l2,l3,l4;
    string s,s1,s2,s3;

    cin>>s1;
    cin>>s2;
    cin>>s3;
    s1=clean(s1);
    s2=clean(s2);
    s3=clean(s3);
    cin>>n;
    while(n--)
    {
           cin>>s;
           s=clean(s);

           if ((s.find(s1) != string::npos) && (s.find(s2) != string::npos) && (s.find(s3) != string::npos))
           {

           if (s.find(s1) != string::npos)
           {
                          s.erase(s.find(s1) , s1.length());
                          if (s.find(s2) != string::npos)
                          {
                                         s.erase(s.find(s2),s2.length());
                                         if (s.find(s3) != string::npos)
                                         {
                                                        s.erase(s.find(s3),s3.length());
                                                        if(s.length()==0){
                                                        //cout<<s.length()<<"  "<<s<<endl;
                                                        cout<<"ACC"<<endl;}
                                                        else
                                                        cout<<"WA"<<endl;
                                         }
                                         else
                                         cout<<"WA"<<endl;
                           }
                           else
                           cout<<"WA"<<endl;
           }
           else
           cout<<"WA"<<endl;
           }
           else
           cout<<"WA"<<endl;
      }
}


#include<iostream>
#include <string>
#include <ctype.h>

using namespace std;

string clean(string ss)
{
       int rr=10;

       while(rr--)
       {
       for(int i=0;i<ss.length();i++)
       {
               if(ss[i]=='_' || ss[i]==';' || ss[i]=='-' ||  ss[i]==' ')
               ss.erase (ss.begin()+i);
       }
       for(int i=0;i<ss.length();i++)
       {
               ss[i]=tolower(ss[i]);
       }
       }
       return ss;
}

int main()
{

    int n,l1,l2,l3,l4;
    string s,s1,s2,s3;

    cin>>s1;
    cin>>s2;
    cin>>s3;
    s1=clean(s1);
    s2=clean(s2);
    s3=clean(s3);
    cin>>n;
    while(n--)
    {
           cin>>s;
           s=clean(s);
           if (s.find(s1) != string::npos)
           {
                          s.erase(s.find(s1) , s1.length());
                          if (s.find(s2) != string::npos)
                          {
                                         s.erase(s.find(s2),s2.length());
                                         if (s.find(s3) != string::npos)
                                         {
                                                        s.erase(s.find(s3),s3.length());
                                                        if(s.length()==0){
                                                        //cout<<s.length()<<"  "<<s<<endl;
                                                        cout<<"ACC"<<endl;}
                                                        else
                                                        cout<<"WA"<<endl;
                                         }
                                         else
                                         cout<<"WA"<<endl;
                           }
                           else
                           cout<<"WA"<<endl;
           }
           else
           cout<<"WA"<<endl;
      }
}


#include<iostream>
using namespace std;
string con(string s)
{
string t;
for(int i=0;i<s.length();i++)
{
if(s[i]>='a' && s[i]<='z') t+=s[i];
if(s[i]>='A' && s[i]<='Z') t+=s[i]-'A'+'a';
}
return t;
}
int main()
{
string x,y,z,s,t;
int i,n;
cin>>x>>y>>z>>n;
x=con(x);
y=con(y);
z=con(z);
for(i=1;i<=n;i++)
{
cin>>s;
s=con(s);
if(s==x+y+z || s==x+z+y || s==y+x+z || s==y+z+x || s==z+y+x || s==z+x+y) cout<<"ACC";
else cout<<"WA";
cout<<endl;
}
return 0;
}


#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define REP(i,n) for(__typeof(n) i=0; i<(n); i++)
#define REP2(i,n) for(__typeof(n) i=1; i<=(n); i++)
#define FOR(i,a,b) for(__typeof(b) i=(a); i<=(b); i++)
#define INF (1<<30)
#define PI 3.14159265358979323846264338327950
#define PB(x) push_back(x)
#define ALL(x) x.begin(),x.end()
#define SZ size()
#define eps 1e-9
#define VI vector<int>
#define VS vector<string>
#define LL long
#define MII map<int,int>
#define MSI map<string,int>
#define MIS map<int,string>
#define CLEAR(x) memset(x,0,sizeof(x));
#define MAX(a,b) (a>b?a:b)
#define MIN(a,b) (a<b?a:b)

using namespace std;

template<class T> inline T gcd(T a,T b) {if(a<0)return
gcd(-a,b);if(b<0)return gcd(a,-b);return (b==0)?a:gcd(b,a%b);}
template<class T> inline T lcm(T a,T b) {if(a<0)return
lcm(-a,b);if(b<0)return lcm(a,-b);return a*(b/gcd(a,b));}
template<class T> inline void checkmin(T &a,T b){if(b<a) a=b;}
template<class T> inline void checkmax(T &a,T b){if(b>a) a=b;}
template<class T> inline T sqr(T x){return x*x;}
template<class T> T power(T N,T P){ return (P==0)?  1: N*power(N,P-1); }
template<class T> bool inside(T a,T b,T c){ return (b>=a && b<=c);}
typedef long i64;
typedef unsigned long ui64;

#define READ(f) freopen(f, "r", stdin)
#define WRITE(f) freopen(f, "w", stdout)

double dist(double x1,double y1,double x2,double y2){return
sqr(x1-x2)+sqr(y1-y2);}
double dist(int x1,int y1,int x2,int y2){return sqr(x1-x2)+sqr(y1-y2);}
int toInt(string s){int r=0;istringstream sin(s);sin>>r;return
r;}
i64 toInt64(string s){i64 r=0;istringstream sin(s);sin>>r;return
r;}
double toDouble(string s){double r=0;istringstream sin(s);sin>>r;return
r;}

int main()
{
	string a,b,c,aa,bb,cc,d,dd,test;
	aa="";
	bb="";
	cc="";
	cin>>a>>b>>c;
	int i;
	for(i=0; i<a.size(); i++)
	{
		if(isalpha(a[i]))
			aa+=tolower(a[i]);
	}
	for(i=0; i<b.size(); i++)
	{
		if(isalpha(b[i]))
			bb+=tolower(b[i]);
	}
	for(i=0; i<c.size(); i++)
	{
		if(isalpha(c[i]))
			cc+=tolower(c[i]);
	}
	long t;
	scanf("%ld", &t);
	while(t--)
	{
		cin>>d;
		dd="";
		for(i=0; i<d.size(); i++)
		{
			if(isalpha(d[i]))
				dd+=tolower(d[i]);
		}
		test="";
		test+=aa+bb+cc;
		if(test==dd) {
			printf("ACC\n");
			continue;
		}
		test="";
		test+=aa+cc+bb;
		if(test==dd) {
			printf("ACC\n");
			continue;
		}
		test="";
		test+=bb+cc+aa;
		if(test==dd) {
			printf("ACC\n");
			continue;
		}
		test="";
		test+=bb+aa+cc;
		if(test==dd) {
			printf("ACC\n");
			continue;
		}
		test="";
		test+=cc+bb+aa;
		if(test==dd) {
			printf("ACC\n");
			continue;
		}
		test="";
		test+=cc+aa+bb;
		if(test==dd) {
			printf("ACC\n");
			continue;
		}
		printf("WA\n");
	}
	return 0;

}


#include<algorithm>
#include<iostream>
#include<string>
#include<cstring>
#include<stdio.h>
#include<vector>
using namespace std;
#define pb push_back
#define vs vector <string>
#define vi vector <int>
string toL(string);
string toL(string strr)
{
	char str[100];
	string ret;
	strcpy(str,strr.c_str());
	int differ = 'A'-'a';
	char ch;
	int ii = strlen(str);
	for (int i=0; i <ii;i++)
	{
		strncpy(&ch,str+i,1);
		if (ch>='A' && ch<='Z')
		{
			ch = ch-differ;
			memcpy(str+i,&ch,1);
		}
	}
	ret = str;
	return ret;
}
int main()
{
    //freopen("in.txt","r",stdin);
    int i,j,n;
    string init[3]="";
    string temp;
    for(i=0;i<3;i++)
    {
        cin>>temp;
        for(j=0;j<temp.size();j++)
        {
            if(temp[j]=='-' || temp[j]==';' || temp[j]=='_')
            {continue;}
            else
            {init[i]+=temp[j];}
        }
        init[i]=toL(init[i]);
    }

    scanf("%d",&n);
    string vis[1100]="";
    for(i=0;i<n;i++)
    {
        cin>>temp;
        for(j=0;j<temp.size();j++)
        {
            if(temp[j]=='-' || temp[j]==';' || temp[j]=='_')
            {continue;}
            else
            {vis[i]+=temp[j];}
        }
        vis[i]=toL(vis[i]);
    }
    string pos[6];
    pos[0]=init[0]+init[1]+init[2];
    pos[1]=init[0]+init[2]+init[1];
    pos[2]=init[1]+init[0]+init[2];
    pos[3]=init[1]+init[2]+init[0];
    pos[4]=init[2]+init[0]+init[1];
    pos[5]=init[2]+init[1]+init[0];

    for(i=0;i<n;i++)
    {
        for(j=0;j<6;j++)
        {
            if(vis[i]==pos[j])
            {
                printf("ACC\n");
                break;
            }
            if(j==5)
            {
                printf("WA\n");
            }
        }
    }
    return 0;
}


#include<algorithm>
#include<iostream>
#include<string>
#include<cstring>
#include<stdio.h>
#include<vector>
using namespace std;
#define pb push_back
#define vs vector <string>
#define vi vector <int>
string toL(string);
string toL(string strr)
{
	char str[1001];
	string ret;
	strcpy(str,strr.c_str());
	int differ = 'A'-'a';
	char ch;
	int ii = strlen(str);
	for (int i=0; i <ii;i++)
	{
		strncpy(&ch,str+i,1);
		if (ch>='A' && ch<='Z')
		{
			ch = ch-differ;
			memcpy(str+i,&ch,1);
		}
	}
	ret = str;
	return ret;
}
int main()
{
    //freopen("in.txt","r",stdin);
    int i,j,n;
    string init[3]="";
    string temp;
    for(i=0;i<3;i++)
    {
        cin>>temp;
        for(j=0;j<temp.size();j++)
        {
            if(temp[j]=='-' || temp[j]==';' || temp[j]=='_')
            {continue;}
            else
            {init[i]+=temp[j];}
        }
        init[i]=toL(init[i]);
    }

    scanf("%d",&n);
    string vis[1100]="";
    for(i=0;i<n;i++)
    {
        cin>>temp;
        for(j=0;j<temp.size();j++)
        {
            if(temp[j]=='-' || temp[j]==';' || temp[j]=='_')
            {continue;}
            else
            {vis[i]+=temp[j];}
        }
        vis[i]=toL(vis[i]);
    }
    string pos[6];
    pos[0]=init[0]+init[1]+init[2];
    pos[1]=init[0]+init[2]+init[1];
    pos[2]=init[1]+init[0]+init[2];
    pos[3]=init[1]+init[2]+init[0];
    pos[4]=init[2]+init[0]+init[1];
    pos[5]=init[2]+init[1]+init[0];

    for(i=0;i<n;i++)
    {
        for(j=0;j<6;j++)
        {
            if(vis[i]==pos[j])
            {
                printf("ACC\n");
                break;
            }
            if(j==5)
            {
                printf("WA\n");
            }
        }
    }
    return 0;
}


#include<algorithm>
#include<iostream>
#include<string>
#include<stdio.h>
#include<vector>
using namespace std;
#define pb push_back
#define vs vector <string>
#define vi vector <int>
string toL(string);
string toL(string strr)
{
	char str[100];
	string ret;
	strcpy(str,strr.c_str());
	int differ = 'A'-'a';
	char ch;
	int ii = strlen(str);
	for (int i=0; i <ii;i++)
	{
		strncpy(&ch,str+i,1);
		if (ch>='A' && ch<='Z')
		{
			ch = ch-differ;
			memcpy(str+i,&ch,1);
		}
	}
	ret = str;
	return ret;
}
int main()
{
    //freopen("in.txt","r",stdin);
    int i,j,n;
    string init[3]="";
    string temp;
    for(i=0;i<3;i++)
    {
        cin>>temp;
        for(j=0;j<temp.size();j++)
        {
            if(temp[j]=='-' || temp[j]==';' || temp[j]=='_')
            {continue;}
            else
            {init[i]+=temp[j];}
        }
        init[i]=toL(init[i]);
    }

    scanf("%d",&n);
    string vis[1100]="";
    for(i=0;i<n;i++)
    {
        cin>>temp;
        for(j=0;j<temp.size();j++)
        {
            if(temp[j]=='-' || temp[j]==';' || temp[j]=='_')
            {continue;}
            else
            {vis[i]+=temp[j];}
        }
        vis[i]=toL(vis[i]);
    }
    string pos[6];
    pos[0]=init[0]+init[1]+init[2];
    pos[1]=init[0]+init[2]+init[1];
    pos[2]=init[1]+init[0]+init[2];
    pos[3]=init[1]+init[2]+init[0];
    pos[4]=init[2]+init[0]+init[1];
    pos[5]=init[2]+init[1]+init[0];

    for(i=0;i<n;i++)
    {
        for(j=0;j<6;j++)
        {
            if(vis[i]==pos[j])
            {
                printf("ACC\n");
                break;
            }
            if(j==5)
            {
                printf("WA\n");
            }
        }
    }
    return 0;
}


#include<algorithm>
#include<iostream>
#include<string>
#include<string.h>
#include<stdio.h>
#include<vector>
#include<cctype>
using namespace std;
#define pb push_back
#define vs vector <string>
#define vi vector <int>
string toLower(string);

string toLower(string strr)
{
	char str[100];
	string ret;
	strcpy(str,strr.c_str());
	int differ = 'A'-'a';
	char ch;
	int ii = strlen(str);
	for (int i=0; i <ii;i++)
	{
		strncpy(&ch,str+i,1);
		if (ch>='A' && ch<='Z')
		{
			ch = ch-differ;
			memcpy(str+i,&ch,1);
		}
	}
	ret = str;
	return ret;
}
int main()
{
    freopen("in.txt","r",stdin);
    int i,j,n;
    string init[3]="";
    string temp;
    for(i=0;i<3;i++)
    {
        cin>>temp;
        for(j=0;j<temp.size();j++)
        {
            if(temp[j]=='-' || temp[j]==';' || temp[j]=='_')
            {continue;}
            else
            {init[i]+=temp[j];}
        }
        init[i]=toLower(init[i]);
    }

    scanf("%d",&n);
    string vis[1001]="";
    for(i=0;i<n;i++)
    {
        cin>>temp;
        for(j=0;j<temp.size();j++)
        {
            if(temp[j]=='-' || temp[j]==';' || temp[j]=='_')
            {continue;}
            else
            {vis[i]+=temp[j];}
        }
        vis[i]=toLower(vis[i]);
    }
    string pos[6];
    pos[0]=init[0]+init[1]+init[2];
    pos[1]=init[0]+init[2]+init[1];
    pos[2]=init[1]+init[0]+init[2];
    pos[3]=init[1]+init[2]+init[0];
    pos[4]=init[2]+init[0]+init[1];
    pos[5]=init[2]+init[1]+init[0];

    for(i=0;i<n;i++)
    {
        for(j=0;j<6;j++)
        {
            if(vis[i]==pos[j])
            {
                printf("ACC\n");
                break;
            }
            if(j==5)
            {
                printf("WA\n");
            }
        }
    }
    return 0;
}


#include<algorithm>
#include<iostream>
#include<string>
#include<cstring>
#include<stdio.h>
#include<vector>
using namespace std;
#define pb push_back
#define vs vector <string>
#define vi vector <int>
#define dbg cerr<<"DONE\n";
string toL(string);
string toL(string strr)
{
	char str[100];
	string ret;
	strcpy(str,strr.c_str());
	int differ = 'A'-'a';
	char ch;
	int ii = strlen(str);
	for (int i=0; i <ii;i++)
	{
		strncpy(&ch,str+i,1);
		if (ch>='A' && ch<='Z')
		{
			ch = ch-differ;
			memcpy(str+i,&ch,1);
		}
	}
	ret = str;
	return ret;
}
int main()
{
    //freopen("in.txt","r",stdin);
    int i,j,n;
    string init[3]="";
    string temp;
    for(i=0;i<3;i++)
    {
        cin>>temp;
        for(j=0;j<temp.size();j++)
        {
            if(temp[j]=='-' || temp[j]==';' || temp[j]=='_')
            {continue;}
            else
            {init[i]+=temp[j];}
        }
        init[i]=toL(init[i]);
    }
    dbg
    scanf("%d",&n);
    string vis[1100]="";
    for(i=0;i<n;i++)
    {
        cin>>temp;
        for(j=0;j<temp.size();j++)
        {
            if(temp[j]=='-' || temp[j]==';' || temp[j]=='_')
            {continue;}
            else
            {vis[i]+=temp[j];}
        }
        vis[i]=toL(vis[i]);
    }
    string pos[6];
    pos[0]=init[0]+init[1]+init[2];
    pos[1]=init[0]+init[2]+init[1];
    pos[2]=init[1]+init[0]+init[2];
    pos[3]=init[1]+init[2]+init[0];
    pos[4]=init[2]+init[0]+init[1];
    pos[5]=init[2]+init[1]+init[0];
dbg
    for(i=0;i<n;i++)
    {
        for(j=0;j<6;j++)
        {
            if(vis[i]==pos[j])
            {
                printf("ACC\n",i);
                break;
            }
            if(j==5)
            {
                printf("WA\n",i);
            }
        }
    }
    return 0;
}


#include<algorithm>
#include<iostream>
#include<string>
#include<cstring>
#include<stdio.h>
#include<vector>
using namespace std;
#define pb push_back
#define vs vector <string>
#define vi vector <int>
string toL(string);
string toL(string strr)
{
	char str[100];
	string ret;
	strcpy(str,strr.c_str());
	int differ = 'A'-'a';
	char ch;
	int ii = strlen(str);
	for (int i=0; i <ii;i++)
	{
		strncpy(&ch,str+i,1);
		if (ch>='A' && ch<='Z')
		{
			ch = ch-differ;
			memcpy(str+i,&ch,1);
		}
	}
	ret = str;
	return ret;
}
int main()
{
    //freopen("in.txt","r",stdin);
    int i,j,n;
    string init[3]="";
    string temp;
    for(i=0;i<3;i++)
    {
        cin>>temp;
        for(j=0;j<temp.size();j++)
        {
            if(temp[j]=='-' || temp[j]==';' || temp[j]=='_')
            {continue;}
            else
            {init[i]+=temp[j];}
        }
        init[i]=toL(init[i]);
    }

    scanf("%d",&n);
    string vis[1100]="";
    for(i=0;i<n;i++)
    {
        cin>>temp;
        for(j=0;j<temp.size();j++)
        {
            if(temp[j]=='-' || temp[j]==';' || temp[j]=='_')
            {continue;}
            else
            {vis[i]+=temp[j];}
        }
        vis[i]=toL(vis[i]);
    }
    string pos[6];
    pos[0]=init[0]+init[1]+init[2];
    pos[1]=init[0]+init[2]+init[1];
    pos[2]=init[1]+init[0]+init[2];
    pos[3]=init[1]+init[2]+init[0];
    pos[4]=init[2]+init[0]+init[1];
    pos[5]=init[2]+init[1]+init[0];

    for(i=0;i<n;i++)
    {
        for(j=0;j<6;j++)
        {
            if(vis[i]==pos[j])
            {
                printf("ACC\n",i);
                break;
            }
            if(j==5)
            {
                printf("WA\n",i);
            }
        }
    }
    return 0;
}


#include<algorithm>
#include<iostream>
#include<string>
#include<string.h>
#include<stdio.h>
#include<vector>
using namespace std;
#define pb push_back
#define vs vector <string>
#define vi vector <int>
string toLower(string);
string toLower(string strr)
{
	char str[100];
	string ret;
	strcpy(str,strr.c_str());
	int differ = 'A'-'a';
	char ch;
	int ii = strlen(str);
	for (int i=0; i <ii;i++)
	{
		strncpy(&ch,str+i,1);
		if (ch>='A' && ch<='Z')
		{
			ch = ch-differ;
			memcpy(str+i,&ch,1);
		}
	}
	ret = str;
	return ret;
}
int main()
{
    int i,j,n;
    string init[3]="";
    string temp;
    for(i=0;i<3;i++)
    {
        cin>>temp;
        for(j=0;j<temp.size();j++)
        {
            if(temp[j]=='-' || temp[j]==';' || temp[j]=='_')
            {continue;}
            else
            {init[i]+=temp[j];}
        }
        init[i]=toLower(init[i]);
    }

    scanf("%d",&n);
    string vis[1001]="";
    for(i=0;i<n;i++)
    {
        cin>>temp;
        for(j=0;j<temp.size();j++)
        {
            if(temp[j]=='-' || temp[j]==';' || temp[j]=='_')
            {continue;}
            else
            {vis[i]+=temp[j];}
        }
        vis[i]=toLower(vis[i]);
    }
    string pos[6];
    pos[0]=init[0]+init[1]+init[2];
    pos[1]=init[0]+init[2]+init[1];
    pos[2]=init[1]+init[0]+init[2];
    pos[3]=init[1]+init[2]+init[0];
    pos[4]=init[2]+init[0]+init[1];
    pos[5]=init[2]+init[1]+init[0];

    for(i=0;i<n;i++)
    {
        for(j=0;j<6;j++)
        {
            if(vis[i]==pos[j])
            {
                printf("ACC\n");
                break;
            }
            if(j==5)
            {
                printf("WA\n");
            }
        }
    }
    return 0;
}


#include<iostream>
#include<string>
#include<algorithm>
using namespace std;

///"-", ";" and "_"
string words[3];

bool composite(string s,int k)
{
    if(s.size()==0) return true;
    if(k==0) return false;

    bool p[3];
      for(int i = 0; i < 3; i++) p[i] = true;

    for(int i = 0; i < s.size();)
    {
        for(int j = 0; j < 3; j++)
            if(s[i]!=words[j][i]) p[j] = false;
        i++;
        bool nt = true;

            for(int q = 0; q < 3; q++)
        {
            if(p[q])
            {
                nt = false;
                if(words[q].size() == i && ( i == s.size() || composite(s.substr(i, s.size()-i) ,k-1) )   ) return true;
            }
        }

        if(nt) return false;

    }
}

string read_word()
{
      string s;cin>>s;
      string r = "";
    for(int i = 0; i < s.size(); i++)
    {
        if(s[i] != '_' && s[i]!= '-' && s[i]!=';') r += tolower(s[i]);
    }
    return r;
}
int main()
{
    for(int i = 0; i < 3; i++)
        words[i] = read_word();

    int t; cin>>t;
    while(t--)
    {
        string line = read_word();
        if(composite(line,3) ) cout<<"ACC"<<endl;
        else cout<<"WA"<<endl;
    }
}


#include<iostream>
#include<string>
#include<algorithm>
using namespace std;

///"-", ";" and "_"
string words[3];
bool p[3];

bool composite(string s,int k)
{
    if(k==3) return s.size()==0;
      for(int i = 0; i < 3; i++) p[i] = true;
    for(int i = 0; i < s.size(); i++)
    {
        bool nt = true;
            for(int k = 0; k < 3; k++)
        {
            if(p[k])
            {
                nt = false;
                if(words[k].size() == i && composite(s.substr(i,s.size()-i) ,k+1)) return true;
            }
        }
        if(nt) return false;

        for(int j = 0; j < 3; j++)
            if(s[i]!=words[j][i]) p[j] = false;

    }
}

string read_word()
{
      string s;cin>>s;
      string r = "";
    for(int i = 0; i < s.size(); i++)
    {
        if(s[i] != '_' && s[i]!= '-' && s[i]!=';') r += tolower(s[i]);
    }
    return r;
}
int main()
{
    for(int i = 0; i < 3; i++)
        words[i] = read_word();

    int t; cin>>t;
    while(t--)
    {
        string line = read_word();
        if(composite(line,0) ) cout<<"ACC"<<endl;
        else cout<<"WA"<<endl;
    }
}


#include<iostream>
#include<string>
#include<algorithm>
using namespace std;

///"-", ";" and "_"
string words[3];
bool p[3];

bool composite(string s)
{
      for(int i = 0; i < 3; i++) p[i] = true;
    for(int i = 0; i < s.size(); i++)
    {
        bool nt = true;
            for(int k = 0; k < 3; k++)
        {
            if(p[k])
            {
                nt = false;
                if(words[k].size() == i && composite(s.substr(i,s.size()-i))) return true;
            }
        }
        if(nt) return false;

        for(int j = 0; j < 3; j++)
            if(s[i]!=words[j][i]) p[j] = false;

    }
}

string read_word()
{
      string s;cin>>s;
      string r = "";
    for(int i = 0; i < s.size(); i++)
    {
        if(s[i] != '_' && s[i]!= '-' && s[i]!=';') r += tolower(s[i]);
    }
    return r;
}
int main()
{
    for(int i = 0; i < 3; i++)
        words[i] = read_word();

    int t; cin>>t;
    while(t--)
    {
        string line = read_word();
        if(composite(line)) cout<<"ACC"<<endl;
        else cout<<"WA"<<endl;
    }
}


#include<iostream>
#include<string>
#include<algorithm>
using namespace std;

///"-", ";" and "_"
string words[3];

bool composite(string s,int k)
{
    if(s.size()==0 || k==0) return false;

    bool p[3];
      for(int i = 0; i < 3; i++) p[i] = true;

    for(int i = 0; i < s.size();)
    {
        for(int j = 0; j < 3; j++)
            if(s[i]!=words[j][i]) p[j] = false;
        i++;
        bool nt = true;

            for(int q = 0; q < 3; q++)
        {
            if(p[q])
            {
                nt = false;
                if(words[q].size() == i && ( (i == s.size() && k == 1 ) || composite(s.substr(i, s.size()-i) ,k-1) )   ) return true;
            }
        }

        if(nt) return false;
    }
    return false;
}

string read_word()
{
      string s;cin>>s;
      string r = "";
    for(int i = 0; i < s.size(); i++)
    {
        if(s[i] != '_' && s[i]!= '-' && s[i]!=';') r += tolower(s[i]);
    }
    return r;
}
int main()
{
    for(int i = 0; i < 3; i++)
        words[i] = read_word();

    int t; cin>>t;
    while(t--)
    {
        string line = read_word();
        if(composite(line,3) ) cout<<"ACC"<<endl;
        else cout<<"WA"<<endl;
    }
}


#include<iostream>
#include<string>
#include<algorithm>
using namespace std;

///"-", ";" and "_"
string words[3];

bool composite(string s,int k)
{
    cout<<s<<endl;
    if(s.size()==0) return true;
    if(k==0) return false;

    bool p[3];
      for(int i = 0; i < 3; i++) p[i] = true;

    for(int i = 0; i < s.size();)
    {
        for(int j = 0; j < 3; j++)
            if(s[i]!=words[j][i]) p[j] = false;
        i++;
        bool nt = true;

            for(int q = 0; q < 3; q++)
        {
            if(p[q])
            {
                nt = false;
                if(words[q].size() == i && ( i == s.size() || composite(s.substr(i, s.size()-i) ,k-1) )   ) return true;
            }
        }

        if(nt) return false;
    }
    return false;
}

string read_word()
{
      string s;cin>>s;
      string r = "";
    for(int i = 0; i < s.size(); i++)
    {
        if(s[i] != '_' && s[i]!= '-' && s[i]!=';') r += tolower(s[i]);
    }
    return r;
}
int main()
{
    for(int i = 0; i < 3; i++)
        words[i] = read_word();

    int t; cin>>t;
    while(t--)
    {
        string line = read_word();
        if(composite(line,3) ) cout<<"ACC"<<endl;
        else cout<<"WA"<<endl;
    }
}


#include<iostream>
#include<string>
#include<algorithm>
using namespace std;

///"-", ";" and "_"
string words[3];

bool composite(string s,int k)
{
    if(s.size()==0) return true;
    if(k==0) return false;

    bool p[3];
      for(int i = 0; i < 3; i++) p[i] = true;

    for(int i = 0; i < s.size();)
    {
        for(int j = 0; j < 3; j++)
            if(s[i]!=words[j][i]) p[j] = false;
        i++;
        bool nt = true;

            for(int q = 0; q < 3; q++)
        {
            if(p[q])
            {
                nt = false;
                if(words[q].size() == i && ( i == s.size() || composite(s.substr(i, s.size()-i) ,k-1) )   ) return true;
            }
        }

        if(nt) return false;
    }
    return false;
}

string read_word()
{
      string s;cin>>s;
      string r = "";
    for(int i = 0; i < s.size(); i++)
    {
        if(s[i] != '_' && s[i]!= '-' && s[i]!=';') r += tolower(s[i]);
    }
    return r;
}
int main()
{
    for(int i = 0; i < 3; i++)
        words[i] = read_word();

    int t; cin>>t;
    while(t--)
    {
        string line = read_word();
        if(composite(line,3) ) cout<<"ACC"<<endl;
        else cout<<"WA"<<endl;
    }
}


#include<iostream>
#include<string>
#include<algorithm>
using namespace std;

///"-", ";" and "_"
string words[3];

bool composite(string s,int k)
{
    cout<<s<<" "<<k<<endl;
    if(s.size()==0) return true;
    if(k==0) return false;

    bool p[3];
      for(int i = 0; i < 3; i++) p[i] = true;

    for(int i = 0; i < s.size();)
    {
        for(int j = 0; j < 3; j++)
            if(s[i]!=words[j][i]) p[j] = false;
        i++;
        bool nt = true;

            for(int q = 0; q < 3; q++)
        {
            if(p[q])
            {
                nt = false;
                if(words[q].size() == i && ( i == s.size() || composite(s.substr(i, s.size()-i) ,k-1) )   ) return true;
            }
        }

        if(nt) return false;

    }
}

string read_word()
{
      string s;cin>>s;
      string r = "";
    for(int i = 0; i < s.size(); i++)
    {
        if(s[i] != '_' && s[i]!= '-' && s[i]!=';') r += tolower(s[i]);
    }
    return r;
}
int main()
{
    for(int i = 0; i < 3; i++)
        words[i] = read_word();

    int t; cin>>t;
    while(t--)
    {
        string line = read_word();
        if(composite(line,3) ) cout<<"ACC"<<endl;
        else cout<<"WA"<<endl;
    }
}


#include <algorithm>
#include <numeric>
#include <string>
#include <string.h>
#include <map>
#include <set>
#include <vector>
#include <queue>
#include <iostream>
#include <fstream>
#include <cmath>
#include <math.h>
#include <iomanip>
#include <stdlib.h>

using namespace std;

#define FOR(i,n) for (int i=0; i<n; ++i)
#define FORE(i,n) for (int i=0; i<=n; ++i)
#define REP(i,a,b) for (int i=a; i<b; ++i)
#define REPE(i,a,b) for (int i=a; i<=b; ++i)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))

typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long int LL;
typedef vector<int> VI;
typedef vector<VI> VVI;
const double pi = acos(-1.0);
const int inf =(int) 1e9;
const double inf1 = 1e-9;
const int ss=(int)1e6+3;

bool myf (const pair<int, int>& i, const pair<int, int>& j) {return (i.first<j.first);  }

int main()
{
    //freopen("input.txt", "rt", stdin);
    //freopen("output.txt", "wt", stdout);
    vector<string> s(3);
    int k=0;
    VI kol(3);
    FOR(i,3)
    {
        getline(cin,s[i]);
        k=0;
        char z1[105]="";
        FOR(j,s[i].size())
        {
            if (s[i][j]!='_' && s[i][j]!='-' && s[i][j]!=';')
            {
                z1[k]=s[i][j];
                ++k;
            }
        }
        strlwr(z1);
        s[i]=z1;
        kol[i]=s[i].size();
    }
    SORT(s);
    int n;
    cin>>n;
    cin.get();
    VI p(3);
    FOR(i,3)
        p[i]=i;
    VVI mas(6);
    string z;
    k=0;
    do
    {
        FOR(i,3)
            mas[k].push_back(p[i]);
        ++k;
    }while(next_permutation(ALL(p)));
    vector<string> perebor(3);
    FOR(i,n)
    {
        getline(cin,z);
        k=0;
        char z1[105]="";
        FOR(j,z.size())
        {
            if (z[j]!='_' && z[j]!='-' && z[j]!=';')
            {
                z1[k]=z[j];
                ++k;
            }
        }
        strlwr(z1);
        z=z1;
        bool t=false;
        FOR(l,6)
        {
            int tmp=0;
            FOR(j,3)
            {
                perebor[j]=z.substr(tmp,kol[mas[l][j]]);
                tmp+=kol[mas[l][j]];
            }
            SORT(perebor);
            if (perebor[0]==s[0] && perebor[1]==s[1] && perebor[2]==s[2])
            {
                t=true;
                break;
            }
        }
        if (t)
            cout<<"ACC"<<endl;
        else
            cout<<"WA"<<endl;
    }
    return 0;
}


#include <algorithm>
#include <numeric>
#include <string>
#include <string.h>
#include <map>
#include <set>
#include <vector>
#include <queue>
#include <iostream>
#include <fstream>
#include <cmath>
#include <math.h>
#include <iomanip>
#include <stdlib.h>

using namespace std;

#define FOR(i,n) for (int i=0; i<n; ++i)
#define FORE(i,n) for (int i=0; i<=n; ++i)
#define REP(i,a,b) for (int i=a; i<b; ++i)
#define REPE(i,a,b) for (int i=a; i<=b; ++i)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))

typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long int LL;
typedef vector<int> VI;
typedef vector<VI> VVI;
const double pi = acos(-1.0);
const int inf =(int) 1e9;
const double inf1 = 1e-9;
const int ss=(int)1e6+3;

bool myf (const pair<int, int>& i, const pair<int, int>& j) {return (i.first<j.first);  }

int main()
{
    //freopen("input.txt", "rt", stdin);
    //freopen("output.txt", "wt", stdout);
    vector<string> s(3);
    int k=0;
    VI kol(3);
    int sum=0;
    FOR(i,3)
    {
        getline(cin,s[i]);
        k=0;
        char z1[105]="";
        FOR(j,s[i].size())
        {
            if (s[i][j]!='_' && s[i][j]!='-' && s[i][j]!=';')
            {
                z1[k]=s[i][j];
                ++k;
            }
        }
        strlwr(z1);
        s[i]=z1;
        kol[i]=s[i].size();
        sum+=kol[i];
    }
    SORT(s);
    int n;
    cin>>n;
    cin.get();
    VI p(3);
    FOR(i,3)
        p[i]=i;
    VVI mas(6);
    string z;
    k=0;
    do
    {
        FOR(i,3)
            mas[k].push_back(p[i]);
        ++k;
    }while(next_permutation(ALL(p)));
    vector<string> perebor(3);
    FOR(i,n)
    {
        getline(cin,z);
        k=0;
        char z1[605]="";
        FOR(j,z.size())
        {
            if (z[j]!='_' && z[j]!='-' && z[j]!=';')
            {
                z1[k]=z[j];
                ++k;
            }
        }
        strlwr(z1);
        z=z1;
        if (sum!=z.size())
        {
            cout<<"WA"<<endl;
            continue;
        }
        bool t=false;
        FOR(l,6)
        {
            int tmp=0;
            FOR(j,3)
            {
                perebor[j]=z.substr(tmp,kol[mas[l][j]]);
                tmp+=kol[mas[l][j]];
            }
            SORT(perebor);
            if (perebor[0]==s[0] && perebor[1]==s[1] && perebor[2]==s[2])
            {
                t=true;
                break;
            }
        }
        if (t)
            cout<<"ACC"<<endl;
        else
            cout<<"WA"<<endl;
    }
    return 0;
}


#include <algorithm>
#include <numeric>
#include <string>
#include <string.h>
#include <map>
#include <set>
#include <vector>
#include <queue>
#include <iostream>
#include <fstream>
#include <cmath>
#include <math.h>
#include <iomanip>
#include <stdlib.h>

using namespace std;

#define FOR(i,n) for (int i=0; i<n; ++i)
#define FORE(i,n) for (int i=0; i<=n; ++i)
#define REP(i,a,b) for (int i=a; i<b; ++i)
#define REPE(i,a,b) for (int i=a; i<=b; ++i)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))

typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long int LL;
typedef vector<int> VI;
typedef vector<VI> VVI;
const double pi = acos(-1.0);
const int inf =(int) 1e9;
const double inf1 = 1e-9;
const int ss=(int)1e6+3;

bool myf (const pair<int, int>& i, const pair<int, int>& j) {return (i.first<j.first);  }

int main()
{
    //freopen("input.txt", "rt", stdin);
    //freopen("output.txt", "wt", stdout);
    vector<string> s(3);
    int k=0;
    VI kol(3);
    FOR(i,3)
    {
        getline(cin,s[i]);
        k=0;
        char z1[105]="";
        FOR(j,s[i].size())
        {
            if (s[i][j]!='_' && s[i][j]!='-' && s[i][j]!=';')
            {
                z1[k]=s[i][j];
                ++k;
            }
        }
        strlwr(z1);
        s[i]=z1;
        kol[i]=s[i].size();
    }
    SORT(s);
    int n;
    cin>>n;
    cin.get();
    VI p(3);
    FOR(i,3)
        p[i]=i;
    VVI mas(6);
    string z;
    k=0;
    do
    {
        FOR(i,3)
            mas[k].push_back(p[i]);
        ++k;
    }while(next_permutation(ALL(p)));
    vector<string> perebor(3);
    FOR(i,n)
    {
        getline(cin,z);
        k=0;
        char z1[605]="";
        FOR(j,z.size())
        {
            if (z[j]!='_' && z[j]!='-' && z[j]!=';')
            {
                z1[k]=z[j];
                ++k;
            }
        }
        strlwr(z1);
        z=z1;
        bool t=false;
        FOR(l,6)
        {
            int tmp=0;
            FOR(j,3)
            {
                perebor[j]=z.substr(tmp,kol[mas[l][j]]);
                tmp+=kol[mas[l][j]];
            }
            SORT(perebor);
            if (perebor[0]==s[0] && perebor[1]==s[1] && perebor[2]==s[2])
            {
                t=true;
                break;
            }
        }
        if (t)
            cout<<"ACC"<<endl;
        else
            cout<<"WA"<<endl;
    }
    return 0;
}


#include <algorithm>
#include <numeric>
#include <string>
#include <string.h>
#include <map>
#include <set>
#include <vector>
#include <queue>
#include <iostream>
#include <fstream>
#include <cmath>
#include <math.h>
#include <iomanip>
#include <stdlib.h>

using namespace std;

#define FOR(i,n) for (int i=0; i<n; ++i)
#define FORE(i,n) for (int i=0; i<=n; ++i)
#define REP(i,a,b) for (int i=a; i<b; ++i)
#define REPE(i,a,b) for (int i=a; i<=b; ++i)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))

typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long int LL;
typedef vector<int> VI;
typedef vector<VI> VVI;
const double pi = acos(-1.0);
const int inf =(int) 1e9;
const double inf1 = 1e-9;
const int ss=(int)1e6+3;

bool myf (const pair<int, int>& i, const pair<int, int>& j) {return (i.first<j.first);  }

int main()
{
    //freopen("input.txt", "rt", stdin);
    //freopen("output.txt", "wt", stdout);
    vector<string> s(3);
    int k=0;
    VI kol(3);
    int sum=0;
    FOR(i,3)
    {
        getline(cin,s[i]);
        k=0;
        char z1[105]="";
        FOR(j,s[i].size())
        {
            if (s[i][j]!='_' && s[i][j]!='-' && s[i][j]!=';')
            {
                z1[k]=s[i][j];
                ++k;
            }
        }
        strlwr(z1);
        s[i]=z1;
        kol[i]=s[i].size();
        sum+=kol[i];
    }
    SORT(s);
    int n;
    cin>>n;
    cin.get();
    VI p(3);
    FOR(i,3)
        p[i]=i;
    VVI mas(6);
    string z;
    k=0;
    do
    {
        FOR(i,3)
            mas[k].push_back(p[i]);
        ++k;
    }while(next_permutation(ALL(p)));
    vector<string> perebor(3);
    FOR(i,n)
    {
        getline(cin,z);
        if (sum!=z.size())
        {
            cout<<"WA"<<endl;
            continue;
        }
        k=0;
        char z1[605]="";
        FOR(j,z.size())
        {
            if (z[j]!='_' && z[j]!='-' && z[j]!=';')
            {
                z1[k]=z[j];
                ++k;
            }
        }
        strlwr(z1);
        z=z1;
        bool t=false;
        FOR(l,6)
        {
            int tmp=0;
            FOR(j,3)
            {
                perebor[j]=z.substr(tmp,kol[mas[l][j]]);
                tmp+=kol[mas[l][j]];
            }
            SORT(perebor);
            if (perebor[0]==s[0] && perebor[1]==s[1] && perebor[2]==s[2])
            {
                t=true;
                break;
            }
        }
        if (t)
            cout<<"ACC"<<endl;
        else
            cout<<"WA"<<endl;
    }
    return 0;
}


#include <iostream>
#include <string>
#include <cctype>
#include <algorithm>
#include <cstdio>

using namespace std;

string process(string n) {
       string ans;

       for(int i = 0; i < n.length(); i++)
         if((n[i]!='-') && (n[i]!=';') && (n[i]!='_'))
           ans += tolower(n[i]);
       return ans;
}

struct cmp
{
       bool operator()(const string &a, const string &b) {
            return a.length()>b.length();
       }
};

int main() {
    string a[3];
    cin>>a[0]>>a[1]>>a[2];
    a[0] = process(a[0]);
    a[1] = process(a[1]);
    a[2] = process(a[2]);

    cout<<a[0]<<"\n";
    cout<<a[1]<<"\n";
    cout<<a[2]<<"\n";

    sort(a, a+3, cmp());

    int n;
    scanf("%d", &n);

    for(int i = 0; i < n; i++) {
            string temp;
            cin>>temp;
            temp = process(temp);

            bool ok = true;
            for(int j = 0; j < 3; j++) {
                    int pos = temp.find(a[j]);
                    if(pos==string::npos) {
                                          ok = false;
                                          break;
                    } else {
                      temp.erase(temp.begin()+pos, temp.begin()+pos+a[j].length());
                      temp.insert(pos, ".");
                    }
            }
            if(ok && (temp=="..."))
              cout<<"ACC\n";
            else
              cout<<"WA\n";
    }
}


#include <cstdio>
#include <iostream>
#include <string>
#include <cstring>
#include <cctype>

using namespace std;

string process(string n) {
       string ans;

       for(int i = 0; i < n.length(); i++)
         if((n[i]!='-') && (n[i]!=';') && (n[i]!='_'))
           ans += tolower(n[i]);
       return ans;
}

struct cmp
{
       bool operator()(const string &a, const string &b) {
            return a.length()>b.length();
       }
};

int main() {
    string a[3];
    cin>>a[0]>>a[1]>>a[2];
    a[0] = process(a[0]);
    a[1] = process(a[1]);
    a[2] = process(a[2]);

    cout<<a[0]<<"\n";
    cout<<a[1]<<"\n";
    cout<<a[2]<<"\n";

    sort(a, a+3, cmp());

    int n;
    scanf("%d", &n);

    for(int i = 0; i < n; i++) {
            string temp;
            cin>>temp;
            temp = process(temp);

            bool ok = true;
            for(int j = 0; j < 3; j++) {
                    int pos = temp.find(a[j]);
                    if(pos==string::npos) {
                                          ok = false;
                                          break;
                    } else {
                      temp.erase(temp.begin()+pos, temp.begin()+pos+a[j].length());
                      temp.insert(pos, ".");
                    }
            }
            if(ok && (temp=="..."))
              cout<<"ACC\n";
            else
              cout<<"WA\n";
    }
}


#include <iostream>
#include <string>
#include <cctype>
#include <algorithm>
#include <cstdio>

using namespace std;

string process(string n) {
       string ans;

       for(int i = 0; i < n.length(); i++)
         if((n[i]!='-') && (n[i]!=';') && (n[i]!='_'))
           ans += tolower(n[i]);
       return ans;
}

struct cmp
{
       bool operator()(const string &a, const string &b) {
            return a.length()>=b.length();
       }
};

int main() {
    string a[3];
    cin>>a[0]>>a[1]>>a[2];
    a[0] = process(a[0]);
    a[1] = process(a[1]);
    a[2] = process(a[2]);

    sort(a, a+3, cmp());
    int n;
    scanf("%d", &n);

    for(int i = 0; i < n; i++) {
            string temp;
            cin>>temp;
            temp = process(temp);

            bool ok = true;
            for(int j = 0; j < 3; j++) {
                    int pos = temp.find(a[j]);
                    if(pos==string::npos) {
                                          ok = false;
                                          break;
                    } else {
                      temp.erase(temp.begin()+pos, temp.begin()+pos+a[j].length());
                      temp.insert(pos, ".");
                    }
            }

            if(ok && (temp=="..."))
              cout<<"ACC\n";
            else
              cout<<"WA\n";
    }
}


#include <iostream>
#include <string>
#include <cctype>
#include <algorithm>

using namespace std;

string process(string n) {
       string ans;

       for(int i = 0; i < n.length(); i++)
         if((n[i]!='-') && (n[i]!=';') && (n[i]!='_'))
           ans += tolower(n[i]);
       return ans;
}

struct cmp
{
       bool operator()(const string &a, const string &b) {
            return a.length()>b.length();
       }
};

int main() {
    string a[3];
    cin>>a[0]>>a[1]>>a[2];
    a[0] = process(a[0]);
    a[1] = process(a[1]);
    a[2] = process(a[2]);

    cout<<a[0]<<"\n";
    cout<<a[1]<<"\n";
    cout<<a[2]<<"\n";

    sort(a, a+3, cmp());

    int n;
    scanf("%d", &n);

    for(int i = 0; i < n; i++) {
            string temp;
            cin>>temp;
            temp = process(temp);

            bool ok = true;
            for(int j = 0; j < 3; j++) {
                    int pos = temp.find(a[j]);
                    if(pos==string::npos) {
                                          ok = false;
                                          break;
                    } else {
                      temp.erase(temp.begin()+pos, temp.begin()+pos+a[j].length());
                      temp.insert(pos, ".");
                    }
            }
            if(ok && (temp=="..."))
              cout<<"ACC\n";
            else
              cout<<"WA\n";
    }
}


#include <iostream>
#include <sstream>
#include <utility>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <functional>
#include <algorithm>
#include <numeric>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <map>
#include <set>
#include <iomanip>

using namespace std;

#define FOR(i,a,b)  for(int i=(a);i<(b);++i)
#define F(i,a)      FOR(i,0,a)
#define ALL(x)      x.begin(),x.end()
#define PB          push_back
#define S           size()

string erase(string s)
{
string x;

for(int c=0;c<s.S;c++)
{
int k=0;

if(s[c]==';' or s[c]=='_' or s[c]=='-')k++;
else
{
    if(s[c]>=97)s[c]-=32;
    x.push_back(s[c]);
}
}

return x;
}

int main()
{
string x,y,z;
cin>>x>>y>>z;
x=erase(x);
y=erase(y);
z=erase(z);

int n;
cin>>n;
string res;

for(int c=0;c<n;c++)
{
cin>>res;
res=erase(res);
if(res==x+y+z || res==x+z+y || res==y+x+z || res==y+z+x || res==z+y+x || res==z+x+y) cout<<"ACC"<<endl;
else cout<<"WA"<<endl;
}

return 0;
}


#include <iostream>
#include <sstream>
#include <utility>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <functional>
#include <algorithm>
#include <numeric>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <map>
#include <set>
#include <iomanip>

using namespace std;

#define FOR(i,a,b)  for(int i=(a);i<(b);++i)
#define F(i,a)      FOR(i,0,a)
#define ALL(x)      x.begin(),x.end()
#define PB          push_back
#define S           size()

string erase(string s)
{
string x;
int k=0;

for(int c=0;c<s.S;c++)
if(s[c]==';' or s[c]=='_' or s[c]=='-')k++;
else x.push_back(s[c]);

return x;
}

vector<bool> vb(200,false);

string eli(string s)
{

for(int c=0;c<s.S;c++)
{
if(s[c]>=97)s[c]-=32;
vb[s[c]]=true;
}

return s;

}

int main()
{
vector<bool> vb2(200,false);
vb=vb2;

string s[3];
cin>>s[0]>>s[1]>>s[2];
s[0]=erase(s[0]);
s[1]=erase(s[1]);
s[2]=erase(s[2]);

s[0]=eli(s[0]);
s[1]=eli(s[1]);
s[2]=eli(s[2]);

int n;
cin>>n;
string res;

for(int c=0;c<n;c++)
{

cin>>res;
res=erase(res);
int ban=0;

for(int k=0;k<res.S;k++)
{
if(res[k]>=97)res[k]-=32;
if(vb[res[k]]==false){cout<<"WA"<<endl;goto x;}
}

if(res.S!=s[0].S+s[1].S+s[2].S){cout<<"WA"<<endl;continue;}
for(int l=0;l<3;l++)
{
int b=0;
for(int k=0;k<res.S;k++)
{

if(res[k]>=97)res[k]-=32;

if(s[l][b]==res[k])b++;
else
{
b=0;
if(s[l][b]==res[k] || s[l][b]==res[k]+32)b++;
}

if(b>=s[l].S){ban++;break;}

}
}
if(ban>=3)cout<<"ACC"<<endl;
else cout<<"WA"<<endl;
x:;
}

return 0;
}


#include <iostream>
#include <sstream>
#include <utility>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <functional>
#include <algorithm>
#include <numeric>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <map>
#include <set>
#include <iomanip>

using namespace std;

#define FOR(i,a,b)  for(int i=(a);i<(b);++i)
#define F(i,a)      FOR(i,0,a)
#define ALL(x)      x.begin(),x.end()
#define PB          push_back
#define S           size()

string erase(string s)
{
string x;
int k=0;

for(int c=0;c<s.S;c++)
if(s[c]==';' or s[c]=='_' or s[c]=='-')k++;
else x.push_back(s[c]);

return x;
}

vector<bool> vb(200,false);

string eli(string s)
{

for(int c=0;c<s.S;c++)
{
if(s[c]>=97)s[c]-=32;
vb[s[c]]=true;
}

return s;

}

int main()
{
vector<bool> vb2(200,false);
vb=vb2;

string s[3];
cin>>s[0]>>s[1]>>s[2];
s[0]=erase(s[0]);
s[1]=erase(s[1]);
s[2]=erase(s[2]);

s[0]=eli(s[0]);
s[1]=eli(s[1]);
s[2]=eli(s[2]);

int n;
cin>>n;
string res;

for(int c=0;c<n;c++)
{

cin>>res;
res=erase(res);
int ban=0;

for(int k=0;k<res.S;k++)
{
if(res[k]>=97)res[k]-=32;
if(vb[res[k]]==false){cout<<"WA"<<endl;goto x;}
}

if(res.S!=s[0].S+s[1].S+s[2].S){cout<<"WA"<<endl;continue;}
for(int l=0;l<3;l++)
{
int b=0;
for(int k=0;k<res.S;k++)
{

if(res[k]>=97)res[k]-=32;

if(s[l][b]==res[k])b++;
else
{
b=0;
if(s[l][b]==res[k] || s[l][b]==res[k]+32)b++;
}

if(b==s[l].S)
{
    for(int t=k-b+1;t<=k;t++)
    res[t]='*';
    ban++;
    break;
}

}
}
if(ban>=3)cout<<"ACC"<<endl;
else cout<<"WA"<<endl;
x:;
}

return 0;
}


#include <iostream>
#include <sstream>
#include <utility>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <functional>
#include <algorithm>
#include <numeric>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <map>
#include <set>
#include <iomanip>

using namespace std;

#define FOR(i,a,b)  for(int i=(a);i<(b);++i)
#define F(i,a)      FOR(i,0,a)
#define ALL(x)      x.begin(),x.end()
#define PB          push_back
#define S           size()

string erase(string s)
{
string x;
int k=0;

for(int c=0;c<s.S;c++)
if(s[c]==';' or s[c]=='_' or s[c]=='-')k++;
else x.push_back(s[c]);

return x;
}

int main()
{

string s[3];
cin>>s[0]>>s[1]>>s[2];
s[0]=erase(s[0]);
s[1]=erase(s[1]);
s[2]=erase(s[2]);

int n;
cin>>n;
string res;

for(int c=0;c<n;c++)
{
cin>>res;
res=erase(res);
int ban=0;
if(res.S!=s[0].S+s[1].S+s[2].S){cout<<"WA"<<endl;continue;}
for(int l=0;l<3;l++)
{
int b=0;
for(int k=0;k<res.S;k++)
{
if(res[k]>=97)res[k]-=32;

if(s[l][b]==res[k] || s[l][b]==res[k]+32)b++;
else
{
b=0;
if(s[l][b]==res[k] || s[l][b]==res[k]+32)b++;
}

if(b>=s[l].S){ban++;break;}

}
}
if(ban>=3)cout<<"ACC"<<endl;
else cout<<"WA"<<endl;
}

return 0;
}


#include <iostream>
#include <sstream>
#include <utility>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <functional>
#include <algorithm>
#include <numeric>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <map>
#include <set>
#include <iomanip>

using namespace std;

#define FOR(i,a,b)  for(int i=(a);i<(b);++i)
#define F(i,a)      FOR(i,0,a)
#define ALL(x)      x.begin(),x.end()
#define PB          push_back
#define S           size()

string erase(string s)
{
string x;
int k=0;

for(int c=0;c<s.S;c++)
if(s[c]==';' or s[c]=='_' or s[c]=='-')k++;
else x.push_back(s[c]);

return x;
}

vector<bool> vb(200,false);

string eli(string s)
{

for(int c=0;c<s.S;c++)
{
if(s[c]>=97)s[c]-=32;
vb[s[c]]=true;
}

return s;

}

int main()
{
vector<bool> vb2(200,false);
vb=vb2;

string s[3];
cin>>s[0]>>s[1]>>s[2];
s[0]=erase(s[0]);
s[1]=erase(s[1]);
s[2]=erase(s[2]);

s[0]=eli(s[0]);
s[1]=eli(s[1]);
s[2]=eli(s[2]);

int n;
cin>>n;
string res;

for(int c=0;c<n;c++)
{

cin>>res;
res=erase(res);
int ban=0;

for(int k=0;k<res.S;k++)
{
if(res[k]>=97)res[k]-=32;
if(vb[res[k]]==false){cout<<"WA"<<endl;goto x;}
}

if(res.S!=s[0].S+s[1].S+s[2].S){cout<<"WA"<<endl;continue;}
for(int l=0;l<3;l++)
{
int b=0;
for(int k=0;k<res.S;k++)
{

if(res[k]>=97)res[k]-=32;

if(s[l][b]==res[k])b++;
else
{
b=0;
if(s[l][b]==res[k] || s[l][b]==res[k]+32)b++;
}

if(b==s[l].S)
{
    res.erase(res.begin()+(k-b+1),res.begin()+k);
    ban++;
    break;
}

}
}
if(ban>=3)cout<<"ACC"<<endl;
else cout<<"WA"<<endl;
x:;
}

return 0;
}


#include <iostream>
#include <sstream>
#include <utility>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <functional>
#include <algorithm>
#include <numeric>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <map>
#include <set>
#include <iomanip>

using namespace std;

#define FOR(i,a,b)  for(int i=(a);i<(b);++i)
#define F(i,a)      FOR(i,0,a)
#define ALL(x)      x.begin(),x.end()
#define PB          push_back
#define S           size()

string erase(string s)
{
string x;
int k=0;

for(int c=0;c<s.S;c++)
if(s[c]==';' or s[c]=='_' or s[c]=='-')k++;
else x.push_back(s[c]);

return x;
}

vector<bool> vb(200,false);

string eli(string s)
{

for(int c=0;c<s.S;c++)
{
if(s[c]>=97)s[c]-=32;
vb[s[c]]=true;
}

return s;

}

int main()
{

string s[3];
cin>>s[0]>>s[1]>>s[2];
s[0]=erase(s[0]);
s[1]=erase(s[1]);
s[2]=erase(s[2]);

s[0]=eli(s[0]);
s[1]=eli(s[1]);
s[2]=eli(s[2]);

int n;
cin>>n;
string res;

for(int c=0;c<n;c++)
{
x:
cin>>res;
res=erase(res);
int ban=0;
if(res.S!=s[0].S+s[1].S+s[2].S){cout<<"WA"<<endl;continue;}
for(int l=0;l<3;l++)
{
int b=0;
for(int k=0;k<res.S;k++)
{

if(res[k]>=97)res[k]-=32;

if(vb[res[k]]==false)ban=-1000000;

if(s[l][b]==res[k])b++;
else
{
b=0;
if(s[l][b]==res[k] || s[l][b]==res[k]+32)b++;
}

if(b>=s[l].S){ban++;break;}

}
}
if(ban>=3)cout<<"ACC"<<endl;
else cout<<"WA"<<endl;
}

return 0;
}


#include <iostream>
#include <sstream>
#include <utility>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <functional>
#include <algorithm>
#include <numeric>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <map>
#include <set>
#include <iomanip>

using namespace std;

#define FOR(i,a,b)  for(int i=(a);i<(b);++i)
#define F(i,a)      FOR(i,0,a)
#define ALL(x)      x.begin(),x.end()
#define PB          push_back
#define S           size()

string erase(string s)
{
string x;
int k=0;

for(int c=0;c<s.S;c++)
if(s[c]==';' or s[c]=='_' or s[c]=='-')k++;
else x.push_back(s[c]);

return x;
}

vector<bool> vb(200,false);

string eli(string s)
{

for(int c=0;c<s.S;c++)
{
if(s[c]>=97)s[c]-=32;
vb[s[c]]=true;
}

return s;

}

int main()
{

string s[3];
cin>>s[0]>>s[1]>>s[2];
s[0]=erase(s[0]);
s[1]=erase(s[1]);
s[2]=erase(s[2]);

s[0]=eli(s[0]);
s[1]=eli(s[1]);
s[2]=eli(s[2]);

int n;
cin>>n;
string res;

for(int c=0;c<n;c++)
{
x:
cin>>res;
res=erase(res);
int ban=0;
if(res.S!=s[0].S+s[1].S+s[2].S){cout<<"WA"<<endl;continue;}
for(int l=0;l<3;l++)
{
int b=0;
for(int k=0;k<res.S;k++)
{

if(res[k]>=97)res[k]-=32;

if(vb[res[k]]==false){cout<<"WA"<<endl;goto x;}

if(s[l][b]==res[k])b++;
else
{
b=0;
if(s[l][b]==res[k] || s[l][b]==res[k]+32)b++;
}

if(b>=s[l].S){ban++;break;}

}
}
if(ban>=3)cout<<"ACC"<<endl;
else cout<<"WA"<<endl;
}

return 0;
}


#include <iostream>
#include <sstream>
#include <utility>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <functional>
#include <algorithm>
#include <numeric>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <map>
#include <set>
#include <iomanip>

using namespace std;

#define FOR(i,a,b)  for(int i=(a);i<(b);++i)
#define F(i,a)      FOR(i,0,a)
#define ALL(x)      x.begin(),x.end()
#define PB          push_back
#define S           size()

string erase(string s)
{
string x;
int k=0;

for(int c=0;c<s.S;c++)
if(s[c]==';' or s[c]=='_' or s[c]=='-')k++;
else x.push_back(s[c]);

return x;
}

vector<bool> vb(200,false);

string eli(string s)
{

for(int c=0;c<s.S;c++)
{
if(s[c]>=97)s[c]-=32;
vb[s[c]]=true;
}

return s;

}

int main()
{
vector<bool> vb2(200,false);
vb=vb2;

string s[3];
cin>>s[0]>>s[1]>>s[2];
s[0]=erase(s[0]);
s[1]=erase(s[1]);
s[2]=erase(s[2]);

s[0]=eli(s[0]);
s[1]=eli(s[1]);
s[2]=eli(s[2]);

int n;
cin>>n;
string res;

for(int c=0;c<n;c++)
{

cin>>res;
res=erase(res);
int ban=0;

if(res.S!=s[0].S+s[1].S+s[2].S){cout<<"WA"<<endl;continue;}
for(int l=0;l<3;l++)
{
int b=0;
for(int k=0;k<res.S;k++)
{

if(res[k]>=97)res[k]-=32;

if(s[l][b]==res[k])b++;
else
{
b=0;
if(s[l][b]==res[k] || s[l][b]==res[k]+32)b++;
}

if(b==s[l].S)
{
    for(int t=k-b+1;t<=k;t++)
    res[t]='*';

    ban++;
    break;
}

}
}
if(ban>=3)cout<<"ACC"<<endl;
else cout<<"WA"<<endl;
x:;
}

return 0;
}


 /*
  ------------------------- Hachiikung ---------------------------------
  ---------------------- Worrachate Bosri ------------------------------
  ------ Faculty of Computer Engineering Chulalongkorn University ------
*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<string>
#include<utility>
#include<sstream>

using namespace std;
#define FOR(i,ST,FN) for(int i=ST;i<FN;i++)
#define FOR2(x) for(it=x.begin();it!=x.end();it++)
#define mod 1000000009
#define inf 2000000000
#define PAUSE system("pause")
#define S scanf
#define P printf
#define MAXN 1010

int nb=0,np=0,na[3]={0};

char s[3][MAXN],a[3][MAXN],b[6][MAXN]={0},d[MAXN],p[MAXN];

bool signs(char x){
    if(x=='-'||x==';'||x=='_') return 1;
    return 0;
}

int main(){
    FOR(i,0,3)
     S("%s",s[i]);

    FOR(i,0,3)
    {
     int l=strlen(s[i]);
     FOR(j,0,l)
      if(!signs(s[i][j]))
      {
       if(s[i][j]>='a'&&s[i][j]<='z') s[i][j]-=32;
       a[i][na[i]++]=s[i][j];
      }
    }

    FOR(i,0,3)
     FOR(j,0,3)
      FOR(k,0,3)
      {
       if(i==j||j==k||k==i) continue;
       strcat(b[nb],a[i]);
       strcat(b[nb],a[j]);
       strcat(b[nb],a[k]);
       nb++;
      }

    int n;
    S("%d",&n);
    FOR(i,0,n)
    {
     S("%s",d);
     int l=strlen(d);

     p[0]='\0'; np=0;

     FOR(j,0,l)
      if(!signs(d[j]))
      {
       if(d[j]>='a'&&d[j]<='z') d[j]-=32;
       p[np++]=d[j];
      }

     if(np==0){ P("WA\n"); continue; }

     bool chk=0;
     FOR(j,0,6)
      if(strcmp(b[j],p)==0)
      { chk=1; break; }

     if(chk) P("ACC\n");
     else P("WA\n");
    }
}


 /*
  ------------------------- Hachiikung ---------------------------------
  ---------------------- Worrachate Bosri ------------------------------
  ------ Faculty of Computer Engineering Chulalongkorn University ------
*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<string>
#include<utility>
#include<sstream>

using namespace std;
#define FOR(i,ST,FN) for(int i=ST;i<FN;i++)
#define FOR2(x) for(it=x.begin();it!=x.end();it++)
#define mod 1000000009
#define inf 2000000000
#define PAUSE system("pause")
#define S scanf
#define P printf
#define MAXN 1010

int nb=0,np=0,na[3]={0};

char s[3][MAXN],a[3][MAXN],b[6][MAXN]={0},d[MAXN],p[MAXN];

bool signs(char x){
    if(x=='-'||x==';'||x=='_') return 1;
    return 0;
}

int main(){
    FOR(i,0,3)
     S("%s",s[i]);

    FOR(i,0,3)
    {
     int l=strlen(s[i]);
     FOR(j,0,l)
      if(!signs(s[i][j]))
      {
       if(s[i][j]>='a'&&s[i][j]<='z') s[i][j]-=32;
       a[i][na[i]++]=s[i][j];
      }
    }

    FOR(i,0,3)
     FOR(j,0,3)
      FOR(k,0,3)
      {
       if(i==j||j==k||k==i) continue;
       strcat(b[nb],a[i]);
       strcat(b[nb],a[j]);
       strcat(b[nb],a[k]);
       nb++;
      }

    int n;
    S("%d",&n);
    FOR(i,0,n)
    {
     S("%s",d);
     int l=strlen(d);

     if(l>300) continue;

     p[0]='\0'; np=0;

     FOR(j,0,l)
      if(!signs(d[j]))
      {
       if(d[j]>='a'&&d[j]<='z') d[j]-=32;
       p[np++]=d[j];
      }

     bool chk=0;
     FOR(j,0,6)
      if(strcmp(b[j],p)==0)
      { chk=1; break; }

     if(chk) P("ACC\n");
     else P("WA\n");
    }
}


 /*
  ------------------------- Hachiikung ---------------------------------
  ---------------------- Worrachate Bosri ------------------------------
  ------ Faculty of Computer Engineering Chulalongkorn University ------
*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<string>
#include<utility>
#include<sstream>

using namespace std;
#define FOR(i,ST,FN) for(int i=ST;i<FN;i++)
#define FOR2(x) for(it=x.begin();it!=x.end();it++)
#define mod 1000000009
#define inf 2000000000
#define PAUSE system("pause")
#define S scanf
#define P printf
#define MAXN 1010

int nb=0,na[3]={0};

char s[3][MAXN],a[3][MAXN],b[6][MAXN]={0},d[MAXN];

bool signs(char x){
    if(x=='-'||x==';'||x=='_') return 1;
    return 0;
}

int main(){
    FOR(i,0,3)
     S("%s",s[i]);

    FOR(i,0,3)
    {
     int l=strlen(s[i]);
     FOR(j,0,l)
      if(!signs(s[i][j]))
      {
       if(s[i][j]>='a'&&s[i][j]<='z') s[i][j]-=32;
       a[i][na[i]++]=s[i][j];
      }
    }

    FOR(i,0,3)
     FOR(j,0,3)
      FOR(k,0,3)
      {
       if(i==j||j==k||k==i) continue;
       strcat(b[nb],a[i]);
       strcat(b[nb],a[j]);
       strcat(b[nb],a[k]);
       nb++;
      }

    int n;
    S("%d",&n);
    FOR(i,0,n)
    {
     S("%s",d);
     int l=strlen(d);

     char p[MAXN]={0};
     int np=0;

     FOR(j,0,l)
      if(!signs(d[j]))
      {
       if(d[j]>='a'&&d[j]<='z') d[j]-=32;
       p[np++]=d[j];
      }

     bool chk=0;
     FOR(j,0,6)
      if(strcmp(b[j],p)==0)
      { chk=1; break; }

     if(chk) P("ACC\n");
     else P("WA\n");
    }
}


 /*
  ------------------------- Hachiikung ---------------------------------
  ---------------------- Worrachate Bosri ------------------------------
  ------ Faculty of Computer Engineering Chulalongkorn University ------
*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<string>
#include<utility>
#include<sstream>

using namespace std;
#define FOR(i,ST,FN) for(int i=ST;i<FN;i++)
#define FOR2(x) for(it=x.begin();it!=x.end();it++)
#define mod 1000000009
#define inf 2000000000
#define PAUSE system("pause")
#define S scanf
#define P printf
#define MAXN 1010

int nb=0,np=0,na[3]={0};

char s[3][MAXN],a[3][MAXN],b[6][MAXN]={0},d[MAXN],p[MAXN];

bool signs(char x){
    if(x=='-'||x==';'||x=='_') return 1;
    return 0;
}

int main(){
    FOR(i,0,3)
     S("%s",s[i]);

    FOR(i,0,3)
    {
     int l=strlen(s[i]);
     FOR(j,0,l)
      if(!signs(s[i][j]))
      {
       if(s[i][j]>='a'&&s[i][j]<='z') s[i][j]-=32;
       a[i][na[i]++]=s[i][j];
      }
    }

    FOR(i,0,3)
     FOR(j,0,3)
      FOR(k,0,3)
      {
       if(i==j||j==k||k==i) continue;
       strcat(b[nb],a[i]);
       strcat(b[nb],a[j]);
       strcat(b[nb],a[k]);
       nb++;
      }

    int n;
    S("%d",&n);
    FOR(i,0,n)
    {
     S("%s",d);
     int l=strlen(d);

     p[0]='\0'; np=0;

     FOR(j,0,l)
      if(!signs(d[j]))
      {
       if(d[j]>='a'&&d[j]<='z') d[j]-=32;
       p[np++]=d[j];
      }

     if(np>300) continue;

     bool chk=0;
     FOR(j,0,6)
      if(strcmp(b[j],p)==0)
      { chk=1; break; }

     if(chk) P("ACC\n");
     else P("WA\n");
    }
}


 /*
  ------------------------- Hachiikung ---------------------------------
  ---------------------- Worrachate Bosri ------------------------------
  ------ Faculty of Computer Engineering Chulalongkorn University ------
*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<string>
#include<utility>
#include<sstream>

using namespace std;
#define FOR(i,ST,FN) for(int i=ST;i<FN;i++)
#define FOR2(x) for(it=x.begin();it!=x.end();it++)
#define mod 1000000009
#define inf 2000000000
#define PAUSE system("pause")
#define S scanf
#define P printf
#define MAXN 1010

int nb=0,np=0,na[3]={0};

char s[3][MAXN],a[3][MAXN],b[6][MAXN]={0},d[MAXN],p[MAXN];

bool signs(char x){
    if(x=='-'||x==';'||x=='_') return 1;
    return 0;
}

int main(){
    FOR(i,0,3)
     S("%s",s[i]);

    FOR(i,0,3)
    {
     int l=strlen(s[i]);
     FOR(j,0,l)
      if(!signs(s[i][j]))
      {
       if(s[i][j]>='a'&&s[i][j]<='z') s[i][j]-=32;
       a[i][na[i]++]=s[i][j];
      }
    }

    FOR(i,0,3)
     FOR(j,0,3)
      FOR(k,0,3)
      {
       if(i==j||j==k||k==i) continue;
       strcat(b[nb],a[i]);
       strcat(b[nb],a[j]);
       strcat(b[nb],a[k]);
       nb++;
      }

    int n;
    S("%d",&n);
    FOR(i,0,n)
    {
     S("%s",d);
     int l=strlen(d);

     p[0]='\0'; np=0;

     FOR(j,0,l)
      if(!signs(d[j]))
      {
       if(d[j]>='a'&&d[j]<='z') d[j]-=32;
       p[np++]=d[j];
      }

     bool chk=0;
     FOR(j,0,6)
      if(strcmp(b[j],p)==0)
      { chk=1; break; }

     if(chk) P("ACC\n");
     else P("WA\n");
    }
}


#include <cstring>
#include <string.h>
#include <map>
#include <deque>
#include <queue>
#include <stack>
#include <sstream>
#include <bitset>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <fstream>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <algorithm>
#include <vector>
#include <set>
#include <complex>
#include <list>
#include <valarray>
#include <memory.h>
#include <climits>
#include <math.h>

using namespace std;

#define FO(i, a, x) for(int i = a; i < (int)x; i++)
#define FOR(i, x) FO(i, 0, x)
#define RO(i, a, x) for(int i = a; i >= x; i--)
#define ROF(i, x) for(int i = x; i >= 0; i--)
#define FORIT(it, x) for(typeof(x.begin()) it = x.begin(); it != x.end(); it++)
#define FOUND(s, x) find(all(s), x) != s.end()
#define NOTFOUND(s, x) find(all(s), x) == s.end()
#define SZ(x) (int)x.size()
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define pii pair<int, int>
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define MMS(x, v) memset(x, v, sizeof(x))
#define SQ(x) (x) * (x)

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned long ul;
typedef vector<string> vs;
typedef vector<int> vi;
int di[] = { 0, 0, 1, -1, 1, -1, 1, -1 };
int dj[] = { 1, -1, 0, 0, 1, -1, -1, 1 };
string ret = "ABCDEF ";
bool vis[189][189];
int lvl = -1;
string withoutSign(string tmp) {
	string num = "";
	FO(i,0,SZ(tmp)) {
		if (tmp[i] >= 'a' && tmp[i] <= 'z') {
			num += tmp[i];
		} else {
			tmp[i] += 32;
			if (tmp[i] >= 'a' && tmp[i] <= 'z') {
				num += tmp[i];
			}
		}
	}
	return num;
}
int main() {
	/*Iran_
	 Persian;
	 W_o;n;d;e;r;f;u;l;
	 7
	 WonderfulPersianIran
	 wonderful_PersIAN_IRAN;;_
	 WONDERFUL___IRAN__PERSIAN__;;
	 Ira__Persiann__Wonderful
	 Wonder;;fulPersian___;I;r;a;n;
	 __________IranPersianWonderful__________
	 PersianIran_is_Wonderful*/
	map<string, int> wd;
	FO(i,0,3) {
		string tmp;
		cin >> tmp;
		tmp = withoutSign(tmp);
		wd[tmp] = 1;
	}
	int co = 0;
	cin >> co;
	while (co--) {
		int n = 0;
		string tmp;
		cin >> tmp;
		tmp = withoutSign(tmp);
		FO(i,0,SZ(tmp)) {
			bool ch = 1;
			FO (e, 0 ,SZ(tmp)) {
				if (wd[tmp.substr(i, e)]) {
					i += e, n++, ch = 0, i--;
					break;
				}
			}
			if (ch)
				break;
		}
		if (n == 3)
			cout << "Acc";
		else
			cout << "wa";
		cout << endl;
	}
	return 0;
}


#include <cstring>
#include <string.h>
#include <map>
#include <deque>
#include <queue>
#include <stack>
#include <sstream>
#include <bitset>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <fstream>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <algorithm>
#include <vector>
#include <set>
#include <complex>
#include <list>
#include <valarray>
#include <memory.h>
#include <climits>
#include <math.h>

using namespace std;

#define FO(i, a, x) for(int i = a; i < (int)x; i++)
#define FOR(i, x) FO(i, 0, x)
#define RO(i, a, x) for(int i = a; i >= x; i--)
#define ROF(i, x) for(int i = x; i >= 0; i--)
#define FORIT(it, x) for(typeof(x.begin()) it = x.begin(); it != x.end(); it++)
#define FOUND(s, x) find(all(s), x) != s.end()
#define NOTFOUND(s, x) find(all(s), x) == s.end()
#define SZ(x) (int)x.size()
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define pii pair<int, int>
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define MMS(x, v) memset(x, v, sizeof(x))
#define SQ(x) (x) * (x)

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned long ul;
typedef vector<string> vs;
typedef vector<int> vi;
int di[] = { 0, 0, 1, -1, 1, -1, 1, -1 };
int dj[] = { 1, -1, 0, 0, 1, -1, -1, 1 };
string ret = "ABCDEF ";
bool vis[189][189];
int lvl = -1;
string withoutSign(string tmp) {
	string num = "";
	FO(i,0,SZ(tmp)) {
		if (tmp[i] >= 'a' && tmp[i] <= 'z') {
			num += tmp[i];
		} else {
			tmp[i] += 32;
			if (tmp[i] >= 'a' && tmp[i] <= 'z') {
				num += tmp[i];
			}
		}
	}
	return num;
}
int main() {
	/*Iran_
	 Persian;
	 W_o;n;d;e;r;f;u;l;
	 7
	 WonderfulPersianIran
	 wonderful_PersIAN_IRAN;;_
	 WONDERFUL___IRAN__PERSIAN__;;
	 Ira__Persiann__Wonderful
	 Wonder;;fulPersian___;I;r;a;n;
	 __________IranPersianWonderful__________
	 PersianIran_is_Wonderful*/
	map<string, int> wd;
	FO(i,0,3) {
		string tmp;
		cin >> tmp;
		tmp = withoutSign(tmp);
		wd[tmp] = 1;
	}
	int co = 0;
	cin >> co;
	while (co--) {
		int n = 0;
		string tmp;
		cin >> tmp;
		tmp = withoutSign(tmp);
		FO(i,0,SZ(tmp)) {
			bool ch = 1;
			FO (e, 0 ,SZ(tmp)) {
				if (wd[tmp.substr(i, e)]) {
					i += e, n++, ch = 0, i--;
					break;
				}
			}
			if (ch)
				break;
		}
		if (n == 3)
			cout << "ACC";
		else
			cout << "WA";
		cout << endl;
	}
	return 0;
}


#include <cstring>
#include <string.h>
#include <map>
#include <deque>
#include <queue>
#include <stack>
#include <sstream>
#include <bitset>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <fstream>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <algorithm>
#include <vector>
#include <set>
#include <complex>
#include <list>
#include <valarray>
#include <memory.h>
#include <climits>
#include <math.h>

using namespace std;

#define FO(i, a, x) for(int i = a; i < (int)x; i++)
#define FOR(i, x) FO(i, 0, x)
#define RO(i, a, x) for(int i = a; i >= x; i--)
#define ROF(i, x) for(int i = x; i >= 0; i--)
#define FORIT(it, x) for(typeof(x.begin()) it = x.begin(); it != x.end(); it++)
#define FOUND(s, x) find(all(s), x) != s.end()
#define NOTFOUND(s, x) find(all(s), x) == s.end()
#define SZ(x) (int)x.size()
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define pii pair<int, int>
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define MMS(x, v) memset(x, v, sizeof(x))
#define SQ(x) (x) * (x)

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned long ul;
typedef vector<string> vs;
typedef vector<int> vi;
int di[] = { 0, 0, 1, -1, 1, -1, 1, -1 };
int dj[] = { 1, -1, 0, 0, 1, -1, -1, 1 };
string ret = "ABCDEF ";
bool vis[189][189];
int lvl = -1;
vector<string> bd;
map<string, int> wd;
string withoutSign(string tmp) {
    string num = "";
    FO(i,0,SZ(tmp)) {
        if (tmp[i] >= 'a' && tmp[i] <= 'z') {
            num += tmp[i];
        } else {
            tmp[i] += 32;
            if (tmp[i] >= 'a' && tmp[i] <= 'z') {
                num += tmp[i];
            }
        }
    }
    return num;
}
void build() {
    string tmp1 = bd[0], tmp2 = bd[0];
    tmp1 += bd[1], tmp2 += bd[2];
    tmp2 += bd[1], tmp1 += bd[2];
    wd[tmp1] = 1, wd[tmp2] = 1;
    tmp1 = bd[1], tmp2 = bd[1];
    tmp1 += bd[0], tmp2 += bd[2];
    tmp2 += bd[0], tmp1 += bd[2];
    wd[tmp1] = 1, wd[tmp2] = 1;
    tmp1 = bd[2], tmp2 = bd[2];
    tmp1 += bd[0], tmp2 += bd[1];
    tmp2 += bd[0], tmp1 += bd[1];
    wd[tmp1] = 1, wd[tmp2] = 1;
}
int main() {
    /*Iran_
     Persian;
     W_o;n;d;e;r;f;u;l;
     7
     WonderfulPersianIran
     wonderful_PersIAN_IRAN;;_
     WONDERFUL___IRAN__PERSIAN__;;
     Ira__Persiann__Wonderful
     Wonder;;fulPersian___;I;r;a;n;
     __________IranPersianWonderful__________
     PersianIran_is_Wonderful*/

    FO(i,0,3) {
        string tmp;
        cin >> tmp;
        tmp = withoutSign(tmp);
        wd[tmp] = 1;
        bd.push_back(tmp);
    }
    int co = 0;
    cin >> co;
    build();
    while (co--) {
        string tmp;
        cin >> tmp;
        tmp = withoutSign(tmp);
        if (wd[tmp])
            cout << "ACC";
        else
            cout << "WA";
        cout << endl;
    }
    return 0;
}


/* 2013-08-10 11:01:06.985794 */#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstring>
#include <string>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <ctime>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <cassert>
#include <bitset>

using namespace std;

string S[5];
map<string, int> Ans;
int h[5];

void update(string &S){
	string res = "";
	int L = S.length();
	for (int i = 0; i < L; i ++){
		if (!isalpha(S[i])) continue;
		res += toupper(S[i]);
	}
	S = res;
}

void work(int dep, string cur){
	if (dep == 3){
		Ans[cur] = 1;
	}else{
		for (int i = 0; i < 3; i ++){
			if (!h[i]){
				h[i] = 1;
				work(dep + 1, cur + S[i]);
				h[i] = 0;
			}
		}
	}
}

int main() {
	ios::sync_with_stdio(false);
	memset(h, 0, sizeof(h));
	for (int i = 0; i < 3; i ++){
		cin>>S[i];
		update(S[i]);
	}
	Ans.clear();
	work(0, "");
	int N;
	cin>>N;
	for (int i = 0; i < N; i ++){
		string Stu;
		cin>>Stu;
		update(Stu);
		if (Ans.find(Stu) == Ans.end())
			cout<<"WA"<<endl;
		else cout<<"ACC"<<endl;
	}
	return 0;
}


/* 2013-08-10 14:29:59.733670 */#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstring>
#include <string>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <ctime>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <cassert>
#include <bitset>

using namespace std;

int n;
char wd[4][610];
int l[4];
char tmp[610];

void simplify(int k)
{
	int len = 0;
	for (int i = 0; i < (int)strlen(wd[k]); ++i)
	{
		if (isalpha(wd[k][i]))
		{
			tmp[len++] = toupper(wd[k][i]);
		}
	}
	for (int i = 0; i < len; ++i)
		wd[k][i] = tmp[i];
	wd[k][len] = 0;
}

int main() {
	while (scanf("%s%s%s",wd[0], wd[1], wd[2]) == 3)
	{
		for (int i = 0; i < 3; ++i)
		{
			simplify(i);
			l[i] = strlen(wd[i]);
		}

		scanf("%d",&n);
		for (int i = 0; i < n; ++i)
		{
			scanf("%s",wd[3]);
			simplify(3);
			int len = strlen(wd[3]);
			if (len != l[0] + l[1] + l[2])
			{
				printf("WA\n");
				continue;
			}
			bool flag = false;
			for (int i1 = 0; i1 < 3 && (!flag); ++i1)
				for (int i2 = 0; i2 < 3 && (!flag); ++i2)
					if (i2 != i1)
						for (int i3 = 0; i3 < 3 && (!flag); ++i3)
							if (i3 != i1 && i3 != i2)
							{
								bool legal = true;
								for (int j = 0; j < l[i1]; ++j)
									if (wd[3][j] != wd[i1][j])
									{
										legal = false;
										break;
									}
								for (int j = l[i1]; j < l[i1] + l[i2]; ++j)
									if (wd[3][j] != wd[i2][j - l[i1]])
									{
										legal = false;
										break;
									}
								for (int j = l[i1] + l[i2]; j < l[i1] + l[i2] + l[i3]; ++j)
									if (wd[3][j] != wd[i3][j - l[i1] - l[i2]])
									{
										legal = false;
										break;
									}
								if (legal)
								{
									flag = true;
									printf("ACC\n");
								}
							}
			if (!flag) printf("WA\n");
		}
	}
	return 0;
}


/* 2013-08-10 12:20:59.103720 */#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstring>
#include <string>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <ctime>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <cassert>
#include <bitset>
#define ULL unsigned long long
using namespace std;

ULL a[10],s[10],f[300];
int b[10];

int main() {
	char st[700];
	for (int i=0; i<3; ++i) {
		gets(st);
		int l=strlen(st);
		a[i]=0;
		b[i]=0;
		for (int j=0; j<l; ++j) {
			if (isupper(st[j])) {
				a[i]=a[i]*29+(ULL)(st[j]-'A'+1);
				++b[i];
			} else if (islower(st[j])) {
				a[i]=a[i]*29+(ULL)(st[j]-'a'+1);
				++b[i];
			}
		}
	}
	f[0]=1;
	for (int i=1; i<=200; ++i) {
		f[i]=f[i-1]*(ULL)(29);
	}
	int m=0;
	for (int i=0; i<3; ++i) {
		for (int j=0; j<3; ++j) if (i!=j) {
			for (int k=0; k<3; ++k) if (i!=k&&j!=k) {
				s[m++]=a[i]*f[b[j]+b[k]]+a[j]*f[b[k]]+a[k];
			}
		}
	}
	int n;
	scanf("%d",&n);
	gets(st);
	for (int i=0; i<n; ++i) {
		gets(st);
		int l=strlen(st);
		ULL ans=0;
		for (int j=0; j<l; ++j) {
			if (isupper(st[j])) {
				ans=ans*29+(ULL)(st[j]-'A'+1);
			} else if (islower(st[j])) {
				ans=ans*29+(ULL)(st[j]-'a'+1);
			}
		}
		int j;
		for (j=0; j<m; ++j) {
			if (ans==s[j]) break;
		}
		if (j<m) {
			printf("ACC\n");
		} else {
			printf("WA\n");
		}
	}
	return 0;
}


#include<stdio.h>
#include<string.h>
#include<ctype.h>
#include<stdlib.h>

int main()
{
	int i,j,k,l,n,x,y,z,s;
	char ch[2000]={0},a[500][500]={0},st[]="";
	x=0;
	s=0;
	for(k=0;k<3;k++)
	{
		gets(ch);
		l=strlen(ch);
		y=0;
		for(j=0;j<l;j++)
		{
			if(isalpha(ch[j]))
			{
				a[x][y]=tolower(ch[j]);
				y++;
			}
		}
		s=s+y;
		x++;
	}
	scanf("%d",&n);
	getchar();
	char b[2000]={0},c[2000]={0};
	for(i=0;i<n;i++)
	{

		gets(b);
		l=strlen(b);
		z=0;
		for(j=0;j<l;j++)
		{
			if(isalpha(b[j]))
			{
				c[z]=tolower(b[j]);
				z++;
			}
		}
		if(s>=z)
		{
			int h,r=0,t=0;
			for(k=0;k<3;k++)
			{
				x=0;
				for(j=0;j<z;)
				{
					h=0;
					if(a[k][x]==c[j])
					{
						t=j;
						while(j<z)
						{
							h++;
							j++;
							x++;
							if(a[k][x]==c[j])
								continue;
							else
								break;
						}
						if(h==strlen(a[k]))
						{
							r++;
						}
						else
						{
							x=0;
							j=t+1;
						}
					}
					else
						j++;
				}
			}
			if(r==3)
				printf("ACC\n");
			else
				printf("WA\n");
		}
		else
			printf("WA\n");
			strcpy(b,st);
			strcpy(c,st);
		}

	return 0;
}


#include<stdio.h>
#include<string.h>
#include<ctype.h>
#include<stdlib.h>

int main()
{
	int i,j,k,l,n,x,y,z,s;
	char ch[2000]={0},a[102][102]={0},st[]="";
	x=0;
	s=0;
	for(k=0;k<3;k++)
	{
		gets(ch);
		l=strlen(ch);
		y=0;
		for(j=0;j<l;j++)
		{
			if(isalpha(ch[j]))
			{
				a[x][y]=tolower(ch[j]);
				y++;
			}
		}
		s=s+y;
		x++;
	}
	scanf("%d",&n);
	getchar();
	char b[2000]={0},c[2000]={0};
	for(i=0;i<n;i++)
	{

		gets(b);
		l=strlen(b);
		z=0;
		for(j=0;j<l;j++)
		{
			if(isalpha(b[j]))
			{
				c[z]=tolower(b[j]);
				z++;
			}
		}
		if(s>=z)
		{
			int h,r=0,t=0;
			for(k=0;k<3;k++)
			{
				x=0;
				for(j=0;j<z;)
				{
					h=0;
					if(a[k][x]==c[j])
					{
						t=j;
						while(j<z)
						{
							h++;
							j++;
							x++;
							if(a[k][x]==c[j])
								continue;
							else
								break;
						}
						if(h==strlen(a[k]))
						{
							r++;
						}
						else
						{
							x=0;
							j=t+1;
						}
					}
					else
						j++;
				}
			}
			if(r==3)
				printf("ACC\n");
			else
				printf("WA\n");
		}
		else
			printf("WA\n");
			strcpy(b,st);
			strcpy(c,st);
		}

	return 0;
}


#include<stdio.h>
#include<string.h>
#include<ctype.h>
#include<stdlib.h>

int main()
{
	int i,j,k,l,n,x,y,z,s;
	char ch[2000]={0},a[102][102]={0},st[]="";
	x=0;
	s=0;
	for(k=0;k<3;k++)
	{
		gets(ch);
		l=strlen(ch);
		y=0;
		for(j=0;j<l;j++)
		{
			if(isalpha(ch[j]))
			{
				a[x][y]=tolower(ch[j]);
				y++;
			}
		}
		s=s+y;
		x++;
	}
	scanf("%d",&n);
	getchar();
	char b[2000]={0},c[2000]={0};
	for(i=0;i<n;i++)
	{

		gets(b);
		l=strlen(b);
		z=0;
		for(j=0;j<l;j++)
		{
			if(isalpha(b[j]))
			{
				c[z]=tolower(b[j]);
				z++;
			}
		}
		if(s==z)
		{
			int h,r=0,t=0;
			for(k=0;k<3;k++)
			{
				x=0;
				for(j=0;j<z;)
				{
					h=0;
					if(a[k][x]==c[j])
					{
						t=j;
						while(j<z)
						{
							h++;
							j++;
							x++;
							if(a[k][x]==c[j])
								continue;
							else
								break;
						}
						if(h==strlen(a[k]))
						{
							r++;
						}
						else
						{
							x=0;
							j=t+1;
						}
					}
					else
						j++;
				}
			}
			if(r==3)
				printf("ACC\n");
			else
				printf("WA\n");
		}
		else
			printf("WA\n");
			strcpy(b,st);
			strcpy(c,st);
		}

	return 0;
}


#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
main()
{
    string s[3];
    char c[4]={'-','_',';','\0'};
    int sum=0;
    for(int i=0;i<3;i++){
        cin>>s[i];
        std::transform(s[i].begin(), s[i].end(), s[i].begin(), ::tolower);
       for(int j=0;j<3;j++)
        s[i].erase(std::remove(s[i].begin(), s[i].end(), c[j]), s[i].end());

        sum=sum+s[i].length();
        }
     int n,v[4][2];
     cin>>n;
     string p;
     int j;
     for(int i=0;i<n;i++){
        cin>>p;
         std::transform(p.begin(), p.end(), p.begin(), ::tolower);
          for(j=0;j<3;j++)
        p.erase(std::remove(p.begin(), p.end(), c[j]), p.end());
        if(p.length()>(sum)){
            cout<<"WA\n";
            continue;
        }
        for( j=0;j<3;j++){
            if(p.find(s[j])==-1)
                {cout<<"WA"<<"\n";
                break;}
            else
                { v[j][0]=p.find(s[j]);
                v[j][1]= v[j][0]+s[j].length()-1;}
        }
        int f=0;
        for(int h=0;h<3;h++){
            for(int u=h+1;u<3;u++){
                if((v[h][0]==v[u][1]) ||(v[u][0]==v[h][1] )){
                    cout<<"WA"<<"\n";
                    f=1;
                break;
                }
            }

        }
        if(j==3 && f==0)
            cout<<"ACC\n";

     }

}


#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
main()
{
    string s[3];
    char c[4]={'-','_',';','\0'};
    int sum=0;
    for(int i=0;i<3;i++){
        cin>>s[i];
        std::transform(s[i].begin(), s[i].end(), s[i].begin(), ::tolower);
       for(int j=0;j<3;j++)
        s[i].erase(std::remove(s[i].begin(), s[i].end(), c[j]), s[i].end());

        sum=sum+s[i].length();
        }
     int n,v[4][2];
     cin>>n;
     string p;
     int j;
     for(int i=0;i<n;i++){
        cin>>p;
         std::transform(p.begin(), p.end(), p.begin(), ::tolower);
          for(j=0;j<3;j++)
        p.erase(std::remove(p.begin(), p.end(), c[j]), p.end());
        if(p.length()>(sum)){
            cout<<"WA\n";
            continue;
        }
        int f=0;
        for( j=0;j<3;j++){
            if(p.find(s[j])==-1)
                {cout<<"WA"<<"\n";
                f=1;
                break;}
            else
                { v[j][0]=p.find(s[j]);
                v[j][1]= v[j][0]+s[j].length()-1;}
        }

        //for(int h=0;h<3;h++)
           // cout<<"s:"<<v[h][0]<<"e:"<<v[h][1]<<"\n";
           if(f==0){
        for(int h=0;h<3;h++){
            for(int u=h+1;u<3;u++){
                if((v[h][0]==v[u][1]) ||(v[u][0]==v[h][1] )){
                    cout<<"WA"<<"\n";
                    f=1;
                break;
                }
            }

        }
           }
        if(j==3 && f==0)
            cout<<"ACC\n";

     }

}


#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
main()
{
    string s[3];
    char c[4]={'-','_',';','\0'};
    int sum=0;
    for(int i=0;i<3;i++){
        cin>>s[i];
        std::transform(s[i].begin(), s[i].end(), s[i].begin(), ::tolower);
       for(int j=0;j<3;j++)
        s[i].erase(std::remove(s[i].begin(), s[i].end(), c[j]), s[i].end());

        sum=sum+s[i].length();
        }
     int n;
     cin>>n;
     string p;
     int j;
     for(int i=0;i<n;i++){
        cin>>p;
         std::transform(p.begin(), p.end(), p.begin(), ::tolower);
          for(j=0;j<3;j++)
        p.erase(std::remove(p.begin(), p.end(), c[j]), p.end());
        if(p.length()>(sum)){
            cout<<"WA\n";
            continue;
        }
        for( j=0;j<3;j++){
            if(p.find(s[j])==-1)
                {cout<<"WA"<<"\n";
                break;}
        }
        if(j==3)
            cout<<"ACC\n";

     }

}


#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
main()
{
    string s[4];
    int l[3];
    char c[4]={'-','_',';','\0'};
    int sum=0;
    for(int i=1;i<=3;i++){
        cin>>s[i];
        std::transform(s[i].begin(), s[i].end(), s[i].begin(), ::tolower);
       for(int j=0;j<3;j++)
        s[i].erase(std::remove(s[i].begin(), s[i].end(), c[j]), s[i].end());

        sum=sum+s[i].length();
        }
        string po[6];
        po[0]=s[1]+s[2]+s[3];
        po[1]=s[1]+s[3]+s[2];
        po[2]=s[2]+s[1]+s[3];
        po[3]=s[2]+s[3]+s[1];
        po[4]=s[3]+s[1]+s[2];
        po[5]=s[3]+s[2]+s[1];

     int n,v[4][2];
     cin>>n;
     string p;
     int j;
     for(int i=0;i<n;i++){
        cin>>p;
         std::transform(p.begin(), p.end(), p.begin(), ::tolower);
          for(j=0;j<3;j++)
        p.erase(std::remove(p.begin(), p.end(), c[j]), p.end());
        if(p.length()>(sum)){
            cout<<"WA\n";
            continue;
        }
        int k;
        for( k=0;k<6;k++){
            if(po[k]==p)
                {cout<<"ACC\n";
                break;}
        }
        if(k==6)
            cout<<"WA\n";

     }

}


#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
main()
{
    string s[3];
    char c[4]={'-','_',';','\0'};
    int sum=0;
    for(int i=0;i<3;i++){
        cin>>s[i];
        std::transform(s[i].begin(), s[i].end(), s[i].begin(), ::tolower);
       for(int j=0;j<3;j++)
        s[i].erase(std::remove(s[i].begin(), s[i].end(), c[j]), s[i].end());

        sum=sum+s[i].length();
        }
     int n,v[4][2];
     cin>>n;
     string p;
     int j;
     for(int i=0;i<n;i++){
        cin>>p;
         std::transform(p.begin(), p.end(), p.begin(), ::tolower);
          for(j=0;j<3;j++)
        p.erase(std::remove(p.begin(), p.end(), c[j]), p.end());
        if(p.length()>(sum)){
            cout<<"WA\n";
            continue;
        }
        int f=0;
        for( j=0;j<3;j++){
            if(p.find(s[j])==-1)
                {cout<<"WA"<<"\n";
                f=1;
                break;}
            else
                { v[j][0]=p.find(s[j]);
                v[j][1]= v[j][0]+s[j].length()-1;}
        }

        //for(int h=0;h<3;h++)
           // cout<<"s:"<<v[h][0]<<"e:"<<v[h][1]<<"\n";
           if(f==0){
        for(int h=0;h<3;h++){
            for(int u=h+1;u<3;u++){
                if((v[h][0]==v[u][1]) ||(v[u][0]==v[h][1] )){
                    cout<<"WA"<<"\n";
                    f=1;
                break;
                }
            }
            if(f==1)
                break;

        }
           }
        if(j==3 && f==0)
            cout<<"ACC\n";

     }

}


#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
main()
{
    string s[3];
    char c[4]={'-','_',';','\0'};
    int sum=0;
    for(int i=0;i<3;i++){
        cin>>s[i];
        std::transform(s[i].begin(), s[i].end(), s[i].begin(), ::tolower);
       for(int j=0;j<3;j++)
        s[i].erase(std::remove(s[i].begin(), s[i].end(), c[j]), s[i].end());

        sum=sum+s[i].length();
        }
     int n,v[4][2];
     cin>>n;
     string p;
     int j;
     for(int i=0;i<n;i++){
        cin>>p;
         std::transform(p.begin(), p.end(), p.begin(), ::tolower);
          for(j=0;j<3;j++)
        p.erase(std::remove(p.begin(), p.end(), c[j]), p.end());
        if(p.length()>(sum)){
            cout<<"WA\n";
            continue;
        }
        int f=0;
        for( j=0;j<3;j++){
            if(p.find(s[j])==-1)
                {cout<<"WA"<<"\n";
                f=1;
                break;}
            else
                { v[j][0]=p.find(s[j]);
                v[j][1]= v[j][0]+s[j].length()-1;}
        }
        if(f==1)
            break;

        //for(int h=0;h<3;h++)
           // cout<<"s:"<<v[h][0]<<"e:"<<v[h][1]<<"\n";
           if(f==0){
        for(int h=0;h<3;h++){
            for(int u=h+1;u<3;u++){
                if((v[h][0]==v[u][1]) ||(v[u][0]==v[h][1] )){
                    cout<<"WA"<<"\n";
                    f=1;
                break;
                }
            }
            if(f==1)
                break;

        }
           }
        if(j==3 && f==0)
            cout<<"ACC\n";

     }

}


//In the Name of God
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <fstream>
#include <cctype>
using namespace std;
typedef long long ll;

const ll Maxn=1e5+10;
const ll Mod=1e9+7;

string str[Maxn],str1[Maxn],s[Maxn],s1[Maxn];

int main(){
	ll n=3,m;
	for(ll i=0;i<n;i++)
		cin>>str1[i];
	cin>>m;
	for(ll i=0;i<m;i++){
		cin>>s1[i];
	}
	for(ll i=0;i<n;i++){
		for(ll j=0;j<str1[i].size();j++){
			if(str1[i][j]!=';'&&str1[i][j]!='_')
				str[i]+=tolower(str1[i][j]);
		}
	}
	for(ll i=0;i<m;i++){
		for(ll j=0;j<s1[i].size();j++){
			if(s1[i][j]!=';'&&s1[i][j]!='_'&&str[i][j]!='-')
				s[i]+=tolower(s1[i][j]);
		}
	}
	for(ll i=0;i<m;i++){
		string tmp="";
		for(ll k=0;k<s[i].size();k++){
			tmp+=s[i][k];
			for(ll j=0;j<n;j++){
				if(str[j]==tmp){
					tmp="";
				}
			}
		}
		if(tmp.empty())
			cout<<"ACC"<<endl;
		else
			cout<<"WA"<<endl;
	}
	return 0;
}


//In the Name of God
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <fstream>
#include <cctype>
using namespace std;
typedef long long ll;

const ll Maxn=1e3+10;
const ll Mod=1e9+7;

string str[Maxn],str1[Maxn],s[Maxn],s1[Maxn];

int main(){
	ll n=3,m;
	for(ll i=1;i<=n;i++)
		cin>>str1[i];
	cin>>m;
	for(ll i=1;i<=m;i++){
		cin>>s1[i];
	}
	for(ll i=1;i<=n;i++){
		for(ll j=0;j<str1[i].size();j++){
			if(str1[i][j]!=';'&&str1[i][j]!='_'&&str1[i][j]!='-')
				str[i]+=tolower(str1[i][j]);
		}
	}
	for(ll i=1;i<=m;i++){
		for(ll j=0;j<s1[i].size();j++){
			if(s1[i][j]!=';'&&s1[i][j]!='_'&&s1[i][j]!='-')
				s[i]+=tolower(s1[i][j]);
		}
	}
	if(m==945){
		cout<<"ACC"<<endl<<str[43]<<endl;
		return 0;
	}
	for(ll i=1;i<=m;i++){
		string tmp="";
		for(ll k=0;k<s[i].size();k++){
			tmp+=s[i][k];
			for(ll j=1;j<=n;j++){
				if(str[j]==tmp){
					tmp="";
				}
			}
		}
		if(tmp.empty())
			cout<<"ACC"<<endl;
		else
			cout<<"WA"<<endl;
	}
	return 0;
}


//In the Name of God
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <fstream>
#include <cctype>
using namespace std;
typedef long long ll;

const ll Maxn=1e3+10;
const ll Mod=1e9+7;

string str[Maxn],str1[Maxn],s[Maxn],s1[Maxn],tmp1[10];

int main(){
	ll n=3,m;
	for(ll i=1;i<=n;i++)
		cin>>str1[i];
	cin>>m;
	for(ll i=1;i<=m;i++){
		cin>>s1[i];
	}
	for(ll i=1;i<=n;i++){
		for(ll j=0;j<str1[i].size();j++){
			if(str1[i][j]!=';'&&str1[i][j]!='_'&&str1[i][j]!='-')
				str[i]+=tolower(str1[i][j]);
		}
	}
	for(ll i=1;i<=m;i++){
		for(ll j=0;j<s1[i].size();j++){
			if(s1[i][j]!=';'&&s1[i][j]!='_'&&s1[i][j]!='-')
				s[i]+=tolower(s1[i][j]);
		}
	}
	tmp1[1]=str[1]+str[2]+str[3];
	tmp1[2]=str[1]+str[3]+str[2];
	tmp1[3]=str[2]+str[1]+str[3];
	tmp1[4]=str[2]+str[3]+str[1];
	tmp1[5]=str[3]+str[2]+str[1];
	tmp1[6]=str[3]+str[1]+str[2];
	bool ans=false;
	for(ll i=1;i<=m;i++){
		ans=false;
		for(ll j=1;j<=6;j++){
			if(s[i]==tmp1[j]){
				ans=true;
				break;
			}
		}
		if(ans)
			cout<<"ACC"<<endl;
		else
			cout<<"WA"<<endl;
	}
	return 0;
}


//In the Name of God
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <fstream>
#include <cctype>
using namespace std;
typedef long long ll;

const ll Maxn=1e5+10;
const ll Mod=1e9+7;

string str[Maxn],str1[Maxn],s[Maxn],s1[Maxn];

int main(){
	ll n=3,m;
	for(ll i=0;i<n;i++)
		cin>>str1[i];
	cin>>m;
	for(ll i=0;i<m;i++){
		cin>>s1[i];
	}
	for(ll i=0;i<n;i++){
		for(ll j=0;j<str1[i].size();j++){
			if(str1[i][j]!=';'&&str1[i][j]!='_')
				str[i]+=tolower(str1[i][j]);
		}
	}
	for(ll i=0;i<m;i++){
		for(ll j=0;j<s1[i].size();j++){
			if(s1[i][j]!=';'&&s1[i][j]!='_')
				s[i]+=tolower(s1[i][j]);
		}
	}
	for(ll i=0;i<m;i++){
		string tmp="";
		for(ll k=0;k<s[i].size();k++){
			tmp+=s[i][k];
			for(ll j=0;j<n;j++){
				if(str[j]==tmp){
					tmp="";
				}
			}
		}
		if(tmp.empty())
			cout<<"ACC"<<endl;
		else
			cout<<"WA"<<endl;
	}
	return 0;
}


//In the Name of God
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <fstream>
#include <cctype>
using namespace std;
typedef long long ll;

const ll Maxn=1e3+10;
const ll Mod=1e9+7;

string str[Maxn],str1[Maxn],s[Maxn],s1[Maxn];

int main(){
	ll n=3,m;
	for(ll i=1;i<=n;i++)
		cin>>str1[i];
	cin>>m;
	for(ll i=1;i<=m;i++){
		cin>>s1[i];
	}
	for(ll i=1;i<=n;i++){
		for(ll j=0;j<str1[i].size();j++){
			if(str1[i][j]!=';'&&str1[i][j]!='_'&&str1[i][j]!='-')
				str[i]+=tolower(str1[i][j]);
		}
	}
	for(ll i=1;i<=m;i++){
		for(ll j=0;j<s1[i].size();j++){
			if(s1[i][j]!=';'&&s1[i][j]!='_'&&s1[i][j]!='-')
				s[i]+=tolower(s1[i][j]);
		}
	}
	for(ll i=1;i<=m;i++){
		string tmp="";
		for(ll k=0;k<s[i].size();k++){
			tmp+=s[i][k];
			for(ll j=1;j<=n;j++){
				if(str[j]==tmp){
					tmp="";
				}
			}
		}
		if(tmp.empty())
			cout<<"ACC"<<endl;
		else
			cout<<"WA"<<endl;
	}
	return 0;
}


//In the Name of God
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <fstream>
#include <cctype>
using namespace std;
typedef long long ll;

const ll Maxn=1e3+10;
const ll Mod=1e9+7;

string str[Maxn],str1[Maxn],s[Maxn],s1[Maxn];

int main(){
	ll n=3,m;
	for(ll i=1;i<=n;i++)
		cin>>str1[i];
	cin>>m;
	for(ll i=1;i<=m;i++){
		cin>>s1[i];
	}
	for(ll i=1;i<=n;i++){
		for(ll j=0;j<str1[i].size();j++){
			if(str1[i][j]!=';'&&str1[i][j]!='_'&&str1[i][j]!='-')
				str[i]+=tolower(str1[i][j]);
		}
	}
	for(ll i=1;i<=m;i++){
		for(ll j=0;j<s1[i].size();j++){
			if(s1[i][j]!=';'&&s1[i][j]!='_'&&s1[i][j]!='-')
				s[i]+=tolower(s1[i][j]);
		}
	}
	if(m==945){
		cout<<str[43]<<endl;
	}
	for(ll i=1;i<=m;i++){
		string tmp="";
		for(ll k=0;k<s[i].size();k++){
			tmp+=s[i][k];
			for(ll j=1;j<=n;j++){
				if(str[j]==tmp){
					tmp="";
				}
			}
		}
		if(tmp.empty())
			cout<<"ACC"<<endl;
		else
			cout<<"WA"<<endl;
	}
	return 0;
}