// template : rjohari23
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<stdlib.h>
#include<algorithm>
#include<vector>
#define getcx getchar_unlocked
#define pc(x) putchar_unlocked(x);
#ifndef ONLINE_JUDGE
#define getcx getchar
#endif
using namespace std;
#define clear(a) memset((a),0,sizeof(a))
#define pb push_back
#define SIZE(v) v.size()
#define ull unsigned long long int
#define lli long long int
#define li long int
#define ii int
#define mod 1000000007
inline int inp()
{
int n=0;
int ch=getcx();int sign=1;
while( ch < '0' || ch > '9' ){if(ch=='-')sign=-1; ch=getcx();}
while( ch >= '0' && ch <= '9' )
n = (n<<3)+(n<<1) + ch-'0', ch=getcx();
return n*sign;
}
inline long long in()
{
long long n=0;
long long ch=getcx();long long sign=1;
while( ch < '0' || ch > '9' ){if(ch=='-')sign=-1; ch=getcx();}
while( ch >= '0' && ch <= '9' )
n = (n<<3)+(n<<1) + ch-'0', ch=getcx();
return n*sign;
}
inline void write (lli n)
{
lli N = n, rev, count = 0;
rev = N;
if (N == 0) { pc('0');return ;}
while ((rev % 10) == 0) { count++; rev /= 10;} //obtain the count of the number of 0s
rev = 0;
while (N != 0) { rev = (rev<<3) + (rev<<1) + N % 10; N /= 10;} //store reverse of N in rev
while (rev != 0) { pc(rev % 10 + '0'); rev /= 10;}
while (count--) pc('0');
}
/* http://d...content-available-to-author-only...f.com/questions/20106/fast-string-input */
/* fast string input using getchar_unlocked */
inline string ip()
{
string s = "";
int temp=getchar_unlocked();
while ( temp<'0'||temp>'9' )
temp = getchar_unlocked();
while ( temp>='0'&&temp<='9' )
{
s += (char)temp;
temp = getchar_unlocked();
}
return s;
}
int main()
{
ii t;
t = inp();
while ( t-- )
{
string s1,s2,ans;
s1 = ip(); s2 = ip();
ans = s1;
sort(s1.begin(),s1.end());
do
{
if ( s1[0]!='0' )
ans = min(ans,s1);
}
while(next_permutation(s1.begin(),s1.end()));
if ( s2==ans )
printf("AC\n");
else
printf("WA\n");
}
return 0;
}