#include "bits/stdc++.h"
using namespace std;
const int N=1e3+20;
int t,n,i,j,k,dp[N][N],ans,cnt;
char a[N][N];
int dx[]={-1,-1,0};
int dy[]={-1,0,-1};
bool invalid(int x,int y)
{
return min(x,y)<0 or max(x,y)>=n or a[x][y]=='X';
}
int grundy(int x,int y)
{
int &ans=dp[x][y];
if(ans!=-1) return ans;
set <int> s;
for(int k=0;k<3;k++)
{
int nx=x+dx[k],ny=y+dy[k];
if(invalid(nx,ny)) continue;
s.insert(grundy(nx,ny));
}
int mex=0;
while(s.find(mex)!=s.end()) mex++;
return ans=mex;
}
int main()
{
scanf("%d",&t);
while(t--)
{
scanf("%d",&n);
for(i=0;i<n;i++) scanf(" %s",a[i]);
for(i=0;i<n;i++) for(j=0;j<n;j++) dp[i][j]=-1;
cnt=ans=dp[0][0]=0;
for(i=0;i<n;i++)
for(j=0;j<n;j++)
if(a[i][j]=='K') ans^=grundy(i,j);
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
{
if(a[i][j]!='K') continue;
for(k=0;k<3;k++)
{
int x=i+dx[k],y=j+dy[k];
if(invalid(x,y)) continue;
if((ans^grundy(x,y)^grundy(i,j))==0) cnt++;
}
}
}
if(ans) printf("WIN %d\n",cnt);
else printf("LOSE\n");
}
}
I2luY2x1ZGUgImJpdHMvc3RkYysrLmgiCnVzaW5nIG5hbWVzcGFjZSBzdGQ7CmNvbnN0IGludCBOPTFlMysyMDsKaW50IHQsbixpLGosayxkcFtOXVtOXSxhbnMsY250OwpjaGFyIGFbTl1bTl07CmludCBkeFtdPXstMSwtMSwwfTsKaW50IGR5W109ey0xLDAsLTF9OwoKYm9vbCBpbnZhbGlkKGludCB4LGludCB5KQp7CglyZXR1cm4gbWluKHgseSk8MCBvciBtYXgoeCx5KT49biBvciBhW3hdW3ldPT0nWCc7Cn0KCmludCBncnVuZHkoaW50IHgsaW50IHkpCnsKCWludCAmYW5zPWRwW3hdW3ldOwoJaWYoYW5zIT0tMSkgcmV0dXJuIGFuczsKC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