#!/usr/bin/perl

@lines = <STDIN>;
chomp @lines;

$giant = join(" ",@lines);

@boardtext = ();

for $board (1..11) {
  $bp = $board + 1;
  $giant =~ /Board $board (.*)Board $bp/;
  push @boardtext, $1;
}

$giant =~ /Board 12 (.*)/;
push @boardtext, $1;

$bnum = 1;
foreach $text (@boardtext) {
  $text =~ /Dlr: (\w+) .* Vul: (\S+)(.*)Contract Ld Res Score NS (.*)/;
  $dealer = $1;
  $vul = $2;
  $hands = $3;
  $ntext = $4;
  @pieces = ();
  while ($hands =~ s/ ([SHCD] [AKQJT98765432]+) / /) {
    push @pieces, $1;
  }
  splice(@pieces, 0, 0, "S") if ($pieces[0] =~ /^H/);
  splice(@pieces, 0, 0, "H") if ($pieces[1] =~ /^D/);
  splice(@pieces, 0, 0, "D") if ($pieces[2] =~ /^C/);
  splice(@pieces, 0, 0, "C") if ($pieces[3] =~ /^S/);
  $ttext = join("\n", @pieces[0..3]) . "\n";
  $ltext = join("\n", $pieces[4], $pieces[6], $pieces[8], $pieces[10]) . "\n";
  $rtext = join("\n", $pieces[5], $pieces[7], $pieces[9], $pieces[11]) . "\n";
  $btext = join("\n", @pieces[12..15]) . "\n";
  @hands = ();
  if ($hands =~ " west east ") {
    @hands = ($ttext, $rtext, $ltext, $btext);
  } elsif ($hands =~ " south north ") {
    @hands = ($rtext, $btext, $ttext, $ltext);
  } elsif ($hands =~ " east west ") {
    @hands = ($btext, $ltext, $rtext, $ttext);
  } elsif ($hands =~ " north south ") {
    @hands = ($ltext, $ttext, $btext, $rtext);
  }
  $hands =~ /(\S+)/;
  $scoring = $1;
  @scores = ();
  while ($ntext =~ s/ [NSEW] \S+ [NSEW] \S+ [NSEW] \S+ [NSEW] \S+ (\S+ \S+ \S+ \S+ \S+ \S+)//) {
    push @scores, $1;
  }
  print "Board: $bnum Dealer: $dealer Vulnerability: $vul\n";
  print "North:\n", $hands[0];
  print "East:\n", $hands[1];
  print "West:\n", $hands[2];
  print "South:\n", $hands[3];
  print "Scoring: $scoring\n";
  $pair = 0;
  foreach (@scores) {
    $pair++;
    print "$pair. $_\n";
  }
  print "\n";
  $bnum++;
}

