Time limit
1s
Memory limit
128 MB
Players A and B each have ten cards, one with each digit from 0 to 9. Each player lays out the cards in a chosen order. After the game starts, the order cannot be changed.
The game has 10 rounds. In each round, the next card from both players is revealed. The player with the larger number earns 3 points. If the numbers are equal, both players earn 1 point.
After all 10 rounds, the player with the higher total score wins. If the totals are equal, the winner is the player who won the most recent non-drawn round. If every round was a draw, the game result is a draw.
Given the card order for A and B, compute the final scores and the result.
The input consists of two lines. The first line contains A's 10 card numbers in order, separated by spaces. The second line contains B's 10 card numbers in the same format.
On the first line, print A's total score and B's total score in that order, separated by a space. On the second line, print the game result: A if A wins, B if B wins, or D if the game is a draw.