const
   fin = 'poker.in';
   fout = 'poker.out';
   MaxN = 10;

var
   n : Integer;
   c : array[1..MaxN, 1..2] of Integer;
   p : array[0..MaxN] of Double;



   procedure Solve;
   var
      t : array[1..5] of Integer;
      t1, t2, t3, t4, t5 : Integer;

      function CalcPower(t6, t7 : Integer) : Integer;
      var
         q : array[1..7] of Integer;
         s : array[1..5] of Integer;
         maxPower : Integer;

         function Evaluate : Integer;
         var
            i, j : Integer;
            k : Integer;

            count : array[0..7] of Integer;
            flush, straight : Boolean;
            c4, c3, c2h, c2l, c1 : Integer;
         begin
            // counting numbers
            for i := 0 to 7 do
               count[i] := 0;
            for i := 1 to 5 do
               inc(count[s[i] mod 8]);

            // flush test
            flush := true;
            for i := 2 to 5 do
               if (s[i] div 8) <> (s[1] div 8) then
               begin
                  flush := false;
                  break;
               end;

            // straight test
            straight := true;
            k := 0;
            for i := 0 to 7 do
            begin
               if count[i] = 1 then
                  inc(k)
               else
                  if (count[i] > 1) or ((k > 0) and (k < 5)) then
                  begin
                     straight := false;
                     break;
                  end;
            end;

            c4 := -1; c3 := -1; c2h := -1; c2l := -1;
            for i := 0 to 7 do
            begin
               if count[i] = 4 then c4 := i;
               if count[i] = 3 then c3 := i;
               if count[i] = 2 then
               begin
                  c2l := c2h;
                  c2h := i;
               end;
               if count[i] > 0 then c1 := i;
            end;


            if flush and straight and (c1 = 7) then begin Evaluate := 9 * 64 +   0 * 8 +   0; exit; end;
            if flush and straight              then begin Evaluate := 8 * 64 +  c1 * 8 +   0; exit; end;
            if (c4 <> -1)                      then begin Evaluate := 7 * 64 +  c4 * 8 +   0; exit; end;
            if (c3 <> -1) and (c2h <> -1)      then begin Evaluate := 6 * 64 +  c3 * 8 + c2h; exit; end;
            if flush                           then begin Evaluate := 5 * 64 +  c1 * 8 +   0; exit; end;
            if straight                        then begin Evaluate := 4 * 64 +  c1 * 8 +   0; exit; end;
            if (c3 <> -1)                      then begin Evaluate := 3 * 64 +  c3 * 8 +   0; exit; end;
            if (c2h <> -1) and (c2l <> -1)     then begin Evaluate := 2 * 64 + c2h * 8 + c2l; exit; end;
            if (c2h <> -1)                     then begin Evaluate := 1 * 64 + c2h * 8 +   0; exit; end;
            Evaluate := 0;
         end;

         procedure EvaluateSubset(p, k : Integer);
         var
           j, t : Integer;
         begin
            if k = 5 then
            begin
               t := Evaluate;
               if t > maxPower then
                  maxPower := t;

               exit;
            end;

            for j := p to 3 + k do
            begin
               s[k+1] := q[j];
               EvaluateSubset(j + 1, k + 1);
            end;
         end;

      var
         i : Integer;

      begin
         q[1] := t1; q[2] := t2; q[3] := t3; q[4] := t4; q[5] := t5;
         q[6] := t6;
         q[7] := t7;

         maxPower := 0;
         EvaluateSubset(1, 0);
         CalcPower := maxPower;
     end;

   var
      used : array[0..31] of Boolean;
      i, h : Integer;
      power : array[1..MaxN] of Integer;
      wins : array[0..MaxN] of Longint;
      total : Longint;
      maxPower : Integer;
      bestPlayer : Integer;
   begin
      for i := 0 to 31 do
         used[i] := false;

      for i := 1 to n do
      begin
         if c[i, 2] < c[i, 1] then
         begin
            h := c[i, 1];
            c[i, 1] := c[i, 2];
            c[i, 2] := h;
         end;

         used[c[i, 1]] := true;
         used[c[i, 2]] := true;
         wins[i] := 0;
      end;
      total := 0;

      for t1 := 0 to 31 - 4 do
      if not used[t1] then
      begin
         used[t1] := true;

         for t2 := t1 + 1 to 31 - 3 do
         if not used[t2] then
         begin
            used[t2] := true;

            for t3 := t2 + 1 to 31 - 2 do
            if not used[t3] then
            begin
               used[t3] := true;

               for t4 := t3 + 1 to 31 - 1 do
               if not used[t4] then
               begin
                  used[t4] := true;

                  for t5 := t4 + 1 to 31 do
                  if not used[t5] then
                  begin
                     for i := 1 to n do
                        power[i] := calcPower(c[i, 1], c[i, 2]);

                     maxPower := -1;
                     for i := 1 to n do
                     begin
                        if power[i] > maxPower then
                        begin
                           maxPower := power[i];
                           bestPlayer := i;
                        end else
                           if power[i] = maxPower then
                              bestPlayer := 0;
                     end;

                     inc(total);
                     inc(wins[bestPlayer]);
                  end;

                  used[t4] := false;
               end;

               used[t3] := false
            end;

            used[t2] := false;
         end;

         used[t1] := false;
      end;

      for i := 0 to n do
         p[i] := 100 * wins[i] / total;
   end;



   procedure ReadInput;
   var
      f : Text;
      i : Integer;

      function ReadCard : Integer;
      var
         ch : Char;
         suit, number : Integer;
      begin
         Read(f, ch);
         case ch of
            'P' : suit := 0;
            'K' : suit := 1;
            'H' : suit := 2;
            'T' : suit := 3;
         end;
         Read(f, ch);
         Read(f, ch);
         case ch of
            'A' : number := 7;
            'K' : number := 6;
            'Q' : number := 5;
            'J' : number := 4;
            '1' : begin number := 3; Read(f, ch); end;
            '9' : number := 2;
            '8' : number := 1;
            '7' : number := 0;
         end;
         Readln(f);
         ReadCard := suit * 8 + number;
      end;

   begin
      Assign(f, fin);
      Reset(f);
      Readln(f, n);
      for i := 1 to n do
      begin
         c[i][1] := ReadCard;
         c[i][2] := ReadCard;
      end;
      Close(f);
   end;


   procedure WriteOutput;
   var
      f : Text;
      i : Integer;
   begin
      Assign(f, fout);
      Rewrite(f);
      for i := 1 to n do
         Writeln(f, p[i]:0:2);
      Writeln(f, p[0]:0:2);
      Close(f);
   end;



begin
   ReadInput;
   Solve;
   WriteOutput;
end.
