H. Very Well Informed Domino Player 

Context

Four friends join regularly to play Domino. They are friendly and always ready to spend the night together playing Domino, but they are not uninformed by any means.

One of them, Bob, is specially cautious about the game. He wants to be so very well informed that he wants to know, given the game (the pieces of all the players), which piece should he use first to start the game so that the probability of wining is bigger.

The Problem

The Domino game is fairly easy: there are twenty-eight (28) pieces, each one with two halves. Each half has a number in it, from zero to six, represented as spots in the surface. You can see pieces as pairs of numbers. So, the 28 pieces are composed by: (6,6), (6,5), (6,4), ... (0,0). Pieces can always be seen from both halves, so, for instance, (6,5) is the same piece as (5,6).

In the game there are four (4) players. Pi, with i from 1 to 4. To start the game, each player has seven (7) pieces, (pij1,pij2), with i from 1 to 4, and j from 1 to 7, taken at random, and one of them starts the game putting one piece in the center of the table. Then, all players play in turns putting one piece into the table (if they have one applicable), by joining it with the ones that actually are in the table. To build a set of pieces in the table, the pieces have to "match" by sides. That is, suppose that in the table there are a set of pieces (x1,y1), (x2, y2), (x3, y3) ... (xn, yn). It is always the case that yi = x(i+1). Then, any player can put another piece (j,k), iff x1=j or x1=k or yn=k or yn=j. Suppose that the latter, yn=j holds. The new set of pieces on the table would be:

(x1,y1), (x2, y2), (x3, y3) ... (xn, yn), (j, k).

Note also that, for the purposes of the game, the pieces in the table are equivalent if you put them the other way round, that is,

(k, j), (yn, xn) ... (y3, x3), (y2, x2), (y1, x1).

The game ends when:

  1. One player inserts into the table his or her last piece (he or she wins).
  2. No player can put a new piece. In this case, a sum is computed for each player, counting the numeric value of each part of each piece the player has left. The winner is the player with less points, that is:

    Cw | Cw < Cii ∈ [1, …4]
    where

    Ci =

    javailable  pieces  player  i 
    pij1 + pij2
    and player w wins. Note that if there are more than one player that hold the minimum value, there is no winner of this game.

At a given point, Bob is informed of all the pieces that the other players have received. The pieces of each player are these:

Bob:
Alice:
Peter:
Mike:

The first turn goes to Bob, and he wants to know the probability of wining this game if he starts with any of his pieces... Would you help him?

The Input

The input will be composed of lines. Each line contains the specification of a piece that Bob has (one of the 7 pieces listed above), composed as follows:

Note that at this point, again, (x,y) is equivalent to (y,x).

The Output

For each line of input, the output is another line containing the following:

wins W; loses L

where "W" is the number of all possible games played starting with that piece where Bob wins; and "L" is the number of all possible games played starting with that piece where Bob loses the game.

Sample Input

(2,0)
(0,6)

Sample Output

wins 2738632; loses 3409819
wins 4121220; loses 4678487