type TBod=record x,y:integer; end;
var s:string; 
    i,j:integer;
    p:array[1..2,1..6,0..10]of TBod;

procedure a(x0,y0,h,t:integer);
begin
  inc(p[h,t,0].x);
  p[h,t,p[h,t,0].x].x:=x0;
  p[h,t,p[h,t,0].x].y:=y0;
end;

procedure Pis(h:integer);
var f:boolean;
begin
  f:=true;
  
  for i:=1 to 6 do
    for j:=1 to p[h,i,0].x do
      begin
        if f then f:=false else write(',');
        
        case i of
          1:write('K');
          2:write('Q');
          3:write('R');
          4:write('B');
          5:write('N');
        end;
        
        write(chr(ord('a')+p[h,i,j].x-1));
        write(p[h,i,j].y);
      end;
end;

procedure Sort(h,t,n:integer);
var i,j:integer;
    m:TBod;

function Menej(w1,w2:integer):boolean;
begin
  if p[h,t,w1].y = p[h,t,w2].y then
    Menej:=(p[h,t,w1].x < p[h,t,w2].x)
  else Menej:=(p[h,t,w1].y < p[h,t,w2].y)xor(h=2);
end; 

begin
  for i:=1 to n do
    for j:=1 to n-1 do
      if not Menej(j,j+1)then
        begin m:=p[h,t,j]; p[h,t,j]:=p[h,t,j+1]; p[h,t,j+1]:=m; end; 
end;

BEGIN
  for i:=1 to 2 do
    for j:=1 to 6 do
      p[i,j,0].x:=0;
  
  for j:=8 downto 1 do
    begin
      readln(s); readln(s);
      for i:=1 to 8 do
        case s[4*i-1]of
          'K':a(i,j,1,1);
          'Q':a(i,j,1,2);
          'R':a(i,j,1,3);
          'B':a(i,j,1,4);
          'N':a(i,j,1,5);
          'P':a(i,j,1,6);
          
          'k':a(i,j,2,1);
          'q':a(i,j,2,2);
          'r':a(i,j,2,3);
          'b':a(i,j,2,4);
          'n':a(i,j,2,5);
          'p':a(i,j,2,6);
        end;
    end;
    
  for i:=1 to 2 do
    for j:=1 to 6 do
      if p[i,j,0].x>1 then
        Sort(i,j,p[i,j,0].x);
    
  write('White: '); Pis(1); writeln; 
  write('Black: '); Pis(2); writeln;
END.