uva 220
#include<bits/stdc++.h>
using namespace std;
string a[8],s;
int T;
char ch;
int dist[8][2] = {{-1,0},{-1,1},{0,1},{1,1},{1,0},{1,-1},{0,-1},{-1,-1}};
int f[8];
int pan(int x,int y)
{
bool fi = 0;
for(int i = 0;i < 8; ++i)
{
int xx = x,yy = y;
int t = 0;
while(1)
{
xx += dist[i][0];
yy += dist[i][1];
t++;
if(xx < 0 || xx >= 8 || yy < 0 || yy >= 8) break;
if(a[xx][yy] == '-') break;
if(a[xx][yy] == ch)
{
if(t > 1) f[i] = 1,fi = 1;
break;
}
}
}
if(fi) return 1;
return 0;
}
int check(int k)
{
int ans = 0;
for(int i = 0;i < 8; ++i)
for(int j = 0;j < 8; ++j)
if(a[i][j] == '-' && pan(i,j))
{
ans++;
if(!k)
{
if(ans > 1) printf(" ");
printf("(%d,%d)",i + 1,j + 1);
}
}
return ans;
}
void work(int x,int y)
{
a[x][y] = ch;
for(int t = 0;t < 8; ++t) f[t] = 0;
pan(x,y);
for(int t = 0;t < 8; ++t)
if(f[t])
{
int xx = x,yy = y;
while(1)
{
xx += dist[t][0];
yy += dist[t][1];
if(a[xx][yy] == ch) break;
a[xx][yy] = ch;
}
}
int b = 0,w = 0;
for(int i = 0;i < 8; ++i)
for(int j = 0;j < 8; ++j)
if(a[i][j] == 'B') b++;
else if(a[i][j] == 'W') w++;
printf("Black - %2d White - %2d\n",b,w);
}
int main()
{
scanf("%d",&T);
while(T--)
{
for(int i = 0;i < 8; ++i) cin>>a[i];
cin>>ch;
while(1)
{
cin>>s;
if(s == "Q") break;
if(s == "L")
if(!check(0)) printf("No legal move.\n"); //没有合法操作
else printf("\n");
else
{
if(!check(1))
{
if(ch == 'B') ch = 'W';
else ch = 'B';
} //切换游戏者
work(s[1] - '1',s[2] - '1'); //放棋子
if(ch == 'B') ch = 'W';
else ch = 'B';
}
}
for(int i = 0;i < 8; ++i)
cout<<a[i]<<'\n'; //打印棋盘
if(T) printf("\n");
}
return 0;
}