Junior Card Duel
Two players are engaged in a card game. Initially, each player is dealt a specific number of cards, denoted as (n_1) and (n_2) respectively. During each turn, both players select one card from their hand to reveal simultaneously. The player with the weaker card discards it, while the player with the stronger card retains theirs. If both cards are of equal strength, both are discarded. The game continues until at least one player has no cards left. If one player still has cards remaining, they earn (1) point, and the other player earns (0). If both players run out of cards simultaneously, each receives (0.5) points. There are (N) different types of cards in total. The strength relationship between the cards is not necessarily transitive and is represented by a matrix (A). In this matrix, (A_ij) is (1) if card (i) defeats card (j), and (0) otherwise. The goal is to calculate the maximum average score the first player can achieve, assuming the second player employs a uniform strategy, meaning they choose each card with equal probability.
**Constraints**
- (1 n_1, n_2, N 8) - (A_ij + A_ji = 1) for (i j) - (A_ii = 0)
**Input**
The first line contains the number (N). The next (N) lines each contain (N) numbers, defining the matrix (A). The following line contains the number (n_1) followed by (n_1) numbers, each representing the type of card held by the first player. The next line, in a similar format, describes the cards held by the second player.
**Output**
Output the value of the game for the first player with a precision of at least (10^-8).