|
<p> |
|
In the game of Hold'em Numbers, 4 players play with a deck of <strong>N</strong> cards, where each card has a distinct number from the range [1..<strong>N</strong>] on it. |
|
Each player is dealt two cards and the player who has the highest sum of the two numbers wins. |
|
If multiple players have the highest sum, the one of them who holds the highest card wins. |
|
All 8 cards are dealt simultaneously so it's impossible for two players to have the same card. |
|
</p> |
|
<p> |
|
After seeing your two cards you can bet $1. If you win the hand you get $4 back but if another player wins you lose your dollar. |
|
You can also fold, in which case you don't win nor lose any money. Your opponents play very aggressively and they will always bet. |
|
After the winner is determined all cards are reshuffled to play another hand for the total of <strong>H</strong> games. |
|
It's possible you get dealt the same hand more than once.</p> |
|
</p> |
|
|
|
<p> |
|
You want to maximize your winnings and only bet if your expected winnings are strictly greater than zero. |
|
To help yourself you decided to write a program that for the given deck size and hands you were dealt returns whether you should bet or fold. |
|
</p> |
|
|
|
<h3>Input</h3> |
|
The first line of the input consists of a single integer <strong>T</strong>, the number of test |
|
cases. <br /> |
|
Each test case starts with a line containing two integers <strong>N</strong> and <strong>H</strong><br /> |
|
The subsequent <strong>H</strong> lines each contain two integers, <strong>C1</strong> and <strong>C2</strong>, the cards you were dealt. |
|
</p> |
|
|
|
<h3>Output</h3> |
|
<p> |
|
For each test case <strong>i</strong> numbered from 1 to <strong>T</strong>, output "Case #<strong>i</strong>: ", followed by a string of <strong>H</strong> characters. |
|
Each character being either "B" if you should bet, or "F" if should fold. The order of characters corresponds to the order of hands given in the input. |
|
</p> |
|
|
|
<h3>Constraints</h3> |
|
<p> |
|
1 ≤ <strong>T</strong> ≤ 20 <br /> |
|
8 ≤ <strong>N</strong> ≤ 100 <br /> |
|
1 ≤ <strong>H</strong> ≤ 10000 <br /> |
|
1 ≤ <strong>C1</strong>, <strong>C2</strong> ≤ <strong>N</strong> <br /> |
|
<strong>C1</strong> ≠ <strong>C2</strong> |
|
</p> |
|
|
|
<h3>Examples</h3> |
|
<p>In the first three examples we are playing a single hand with a deck of eight cards. The first case is a clear winner so you should bet. |
|
The second case gives no chance to win and you should fold. |
|
Finally the third case gives you 40% chance of winning. This is good enough to make the bet profitable.</p> |
|
|
|
|