Show Hand (also known as Stud Poker) is a card game played with a standard 52-card deck (A through K, no jokers) consisting of four suits: Spades, Hearts, Clubs, and Diamonds.
The goal of the game is to obtain the best possible hand and win the pot. Each player is initially dealt one hole card, which only they can see. In a standard game, after the hole cards are dealt, each player receives one face-up card in the first round. The player with the highest face-up card acts first, with options to bet, check, or fold. Other players may call, raise, or fold. Players who fold cannot continue in the game, and their previous bets are forfeited. After all-in bets, each player's hand is completed to 5 cards for the final showdown. Subsequent rounds follow a similar process. Finally, players compare their 5-card hands to determine the winner.
The 5-card hand combinations are ranked from highest to lowest as follows:
- Straight Flush: Five cards of the same suit in sequence. Example: $Q\diamondsuit J\diamondsuit 10\diamondsuit 9\diamondsuit 8\diamondsuit$.
- Four of a Kind: Four cards of the same rank. Example: $10\clubsuit 10\diamondsuit 10\heartsuit 10\spadesuit 9\heartsuit$.
- Full House: Three cards of one rank and two cards of another rank. Example: $8\clubsuit 8\diamondsuit 8\spadesuit K\heartsuit K\spadesuit$.
- Flush: Five cards of the same suit. Example: $A\spadesuit K\spadesuit 10\spadesuit 9\spadesuit 8\spadesuit$.
- Straight: Five cards in sequence. Example: $K\diamondsuit Q\heartsuit J\spadesuit 10\diamondsuit 9\diamondsuit$.
- Three of a Kind: Three cards of the same rank. Example: $J\clubsuit J\heartsuit J\spadesuit K\diamondsuit 9\spadesuit$.
- Two Pairs: Two cards of one rank and two cards of another rank. Example: $A\clubsuit A\diamondsuit 8\heartsuit 8\spadesuit Q\spadesuit$.
- One Pair: Two cards of the same rank. Example: $9\heartsuit 9\spadesuit A\clubsuit J\spadesuit 8\heartsuit$.
- Zilch: Hands that do not fit any of the above combinations, ranked by rank. Example: $A\diamondsuit Q\diamondsuit J\spadesuit 9\clubsuit 8\clubsuit$.
If hands are of the same type, the winner is determined by rank and then suit (rank takes priority).
The order of ranks (from high to low) is: $A > K > Q > J > 10 > 9 > 8 > 7 > 6 > 5 > 4 > 3 > 2$. (Note: When the 5-card hand is $5, 4, 3, 2, A$, the $A$ can be treated as the lowest card, making it the lowest possible Straight).
The order of suits (from high to low) is: Spades ($\spadesuit$) > Hearts ($\heartsuit$) > Clubs ($\clubsuit$) > Diamonds ($\diamondsuit$).
Player Y wants to calculate their winning probability in real-time based on the cards they hold and the cards visible on the table.
Input
The first line contains a positive integer $N$, representing the number of cards Player Y holds.
The next $N$ lines each contain two integers describing a card held by Player Y: the first number is the rank ($1$ for $A$, $13$ for $K$, $12$ for $Q$, $11$ for $J$), and the second number is the suit ($1$ for Spades, $2$ for Hearts, $3$ for Clubs, $4$ for Diamonds).
The next $N-1$ lines each contain two integers describing a face-up card held by Player Z: the first number is the rank, and the second number is the suit (using the same mapping as above).
Output
Output a single line in the format $A/B$, where $A$ and $B$ are coprime natural numbers representing the probability of Player Y winning. If $A$ is $0$, output $0/1$.
Examples
Input 1
5 2 1 2 2 2 3 2 4 3 1 1 1 1 2 1 3 3 2
Output 1
42/43
Note 1
Player Y has Four of a Kind. If Player Z's hole card is the $A\diamondsuit$, they would also form Four of a Kind and win due to the higher rank. In all other cases, Player Y wins.
Constraints
For $10\%$ of the data, $N = 5$. For $30\%$ of the data, $3 \le N \le 5$. For $100\%$ of the data, $1 \le N \le 5$.