#include<bits/stdc++.h>

using namespace std ;

int grundy[1001][1001];
int d[1000001],e[1000001];
char c[1001][1001];
int n ;

void init()
{
	for(int i=0;i<=1000;i++)
	{
		for(int j=0;j<=1000;j++)
		grundy[i][j]=-1;
	}
}

int find_grundy ( int x , int y )
{
    if ( x < 1 || y < 1 )
    {
        return - 1 ;    
    }
    else if(c[x][y] == 'X')
    {
    	return -1;
	}
    if ( grundy [ x ] [ y ] != - 1 )
    {
        return grundy [ x ] [ y ] ;    
    }
    set < int > s ;
    int i = 0 ;
    set < int > :: iterator it ;
    s.insert ( find_grundy ( x - 1 , y - 1 ) ) ;
    s.insert ( find_grundy ( x - 1 , y ) ) ;
    s.insert ( find_grundy ( x  , y - 1 ) ) ;
    while ( 1 )
    {
        it = s.find ( i ) ;
        if ( it == s.end () )
        {
            grundy [ x ] [ y ] = i ;
            return i ;
        }
        i ++ ;
    }
}

int main ()
{
    int t ;
    cin >> t;
    while ( t -- )
    {
    	init();
        cin >> n ;
        int z=1;
        for(int i=1;i<=n;i++)
        {
        	for(int j=1;j<=n;j++)
        	{
        		cin>>c[i][j];
        		if(c[i][j] == 'K')
        		{
        			d[z]=i;e[z]=j;z++;
				}
			}
		}
		for ( int i = 1 ; i <= n ; i ++ )
	    {
	        for ( int j = 1 ; j <= n ; j ++ )
	        {
	        	if(c[i][j] == 'X')
	        	grundy[i][j]=0;
	        	else
	            find_grundy ( i , j ) ;
	            //cout << grundy [ i ] [ j ] << " " ;
	        }
	        //cout << endl ;
	    }
        int allxor = 0 ;
        z--;
        int temp = z;
        while ( z  )
        {
            int x , y ;
            x = d[z];
            y = e[z];
            //cout<<x<<" "<<y<<endl;
            allxor = allxor ^ grundy [ x ] [ y ] ;
			z--;   
        }
        //cout<<allxor<<endl;
        if ( allxor == 0 )
        {
            cout <<  "LOSE" << endl ;   
        }
        else
        {
        	int cnt=0;
        	//cout<<temp<<" temp"<<endl;
        	while(temp)
        	{
        		int x , y ;
            	x = d[temp];
            	y = e[temp];
            	if ( x-1 >= 1 and c[x-1][y] != 'X')
            	{
            		allxor = allxor^grundy[x-1][y];
            		allxor = allxor ^grundy[x][y];
            		if(allxor == 0)
            		cnt++;
            		allxor = allxor^grundy[x-1][y];
            		allxor = allxor ^grundy[x][y];
				}
				if ( y-1 >= 1 and c[x][y-1] != 'X')
            	{
            		allxor = allxor^grundy[x][y-1];
            		allxor = allxor ^grundy[x][y];
            		if(allxor == 0)
            		cnt++;
            		allxor = allxor^grundy[x][y-1];
            		allxor = allxor ^grundy[x][y];
				}
				if ( x-1 >= 1  and y-1 >= 1 and c[x-1][y-1] != 'X')
            	{
            		allxor = allxor^grundy[x-1][y-1];
            		allxor = allxor ^grundy[x][y];
            		if(allxor == 0)
            		cnt++;
            		allxor = allxor^grundy[x-1][y-1];
            		allxor = allxor ^grundy[x][y];
				}
				//cout<<allxor<<endl;
				temp--;
			}
            cout << "WIN " << cnt<<endl;    
        }
    }
    return 0 ;
}