program sssa;
type
 TCoord = record
	    x,y: char;
	  end;
 TSet = record
	  data: array[1..64] of TCoord;
	  count: integer;
	end;
var
  MainFirst: boolean;
  S: String;
  i: integer; mainy: integer;
  White: array[1..6] of TSet;
  Black: array[1..6] of TSet;
  
procedure switch_c(var A,B: TCoord);
var
  Tmp: TCoord;
begin
  Tmp:=A;
  A:=B;
  B:=Tmp;
end;


function compare(var A,B: TCoord): boolean;
begin
  if (a.y>b.y) then compare:=false
  else 
    if (a.y<b.y) then compare:=true else
	compare := (b.x>a.x);
end;

procedure sortb(id: integer);
var 
  i,j: integer;
begin
 for i:=1 to Black[id].Count do 
   for j:=2 to Black[id].Count do
     begin
       if compare(Black[id].data[j], black[id].data[j-1]) then switch_c(Black[id].data[j], Black[id].data[j-1]); 
     end;
end;


procedure sortw(id: integer);
var
  i,j: integer;
begin
  for i:=1 to White[id].Count do
    for j:=2 to White[id].Count do
      if compare(white[id].data[j-1], white[id].data[j]) then
        switch_c(white[id].data[j-1], white[id].data[j]);
end;


	
function xlet(x:integer):char;
begin
  xlet:=chr(x+ord('a')-1);
end;

function piecenum(ch:char):integer;
begin
  ch:=UpCase(ch);
  case ch of
   'K': piecenum:=1;
   'Q': piecenum:=2;
   'R': piecenum:=3;
   'B': piecenum:=4;
   'N': piecenum:=5;
   'P': piecenum:=6;
  end;
end;

procedure add(wh: boolean; ch: char; x: integer);
var
  l: char;
  n: integer;
  w: boolean;
begin
  if (ch>='A') and (ch<='Z') then
    w:=true else w:=false;
    
  l:=xlet(x);
  n:=piecenum(ch);
  if (wh) then
    begin
     inc(White[n].Count);
     White[n].Data[White[n].Count].x:=l;
     White[n].Data[White[n].Count].Y:=chr(mainy+$30);
    end else begin
      inc(Black[n].Count);
      Black[n].Data[Black[N].Count].x:=l;
      Black[N].Data[Black[N].Count].Y:=chr(mainy+$30);
    end;

{  Writeln('adding ',piecenum(ch),' for ',xlet(x)); }
end;

function let(i: integer): string;
begin
  case i of
    1: Let:='K';
    2: Let:='Q';
    3: Let:='R';
    4: Let:='B';
    5: Let:='N';
    6: Let:='';
  end;
end;

procedure writew(n: integer);
var
  i: integer;
  first: boolean;
begin
  for i:=1 to White[n].Count do 
  begin
    if mainfirst then mainfirst:=false else write(',');
    Write(let(n),White[n].Data[i].x, White[n].Data[i].y);
  end;
end;

procedure writeb(n: integer);
var
  i: integer;
  first: boolean;
begin
  first:=true;
  for i:=1 to Black[n].Count do 
    begin
      if mainfirst then mainfirst:=false else write(',');
      Write(let(n), Black[n].Data[i].x, Black[n].Data[i].y);
    end;
end;
procedure Process(S: String);
var
  i: integer;
  ch: char;
  x: integer;
  w: boolean;
begin
  i:=3; x:=1;
  while (i<=length(S)) do 
    begin
      if (s[i]>='A') and (s[i]<='Z') then w:=false else w:=true;
      if (s[i]<>'.') and (s[i]<>':') then add(w,s[i],x);
      i:=i+4;
      x:=x+1;
    end;
end;


begin
 
 Readln(S);
 for i:=1 to 6 do White[i].Count:=0;
 for i:=1 to 6 do Black[i].Count:=0;
 
 for mainy:=8 downto 1 do 
   begin
     Readln(S);
     Process(S);
     Readln(S);
   end;


 for i:=1 to 6 do 
   begin
     sortb(i);
   end;

 MainFirst:=true;
 Write('White: ');
 for i:=1 to 6 do WriteB(i);

 Writeln;     
 MainFirst:=true;
 Write('Black: ');
 for i:=1 to 6 do 
   WriteW(i);
  
 Writeln;
 {
 MainFirst:=true;
 Write('White:');   
 for i:=1 to 6 do 
   WriteB(i);
 } 
end.