Codeforces Round 585 (Div. 2)
D
Ticket Game
Codeforces
1700
原题
← CE →
翻译中…

Monocarp and Bicarp live in Berland, where every bus ticket consists of $n$ digits ($n$ is an even number). During the evening walk Monocarp and Bicarp found a ticket where some of the digits have been erased. The number of digits that have been erased is even.

翻译中…

Monocarp and Bicarp have decided to play a game with this ticket. Monocarp hates happy tickets, while Bicarp collects them. A ticket is considered happy if the sum of the first $\frac{n}{2}$ digits of this ticket is equal to the sum of the last $\frac{n}{2}$ digits.

翻译中…

Monocarp and Bicarp take turns (and Monocarp performs the first of them). During each turn, the current player must replace any erased digit with any digit from $0$ to $9$. The game ends when there are no erased digits in the ticket.

翻译中…

If the ticket is happy after all erased digits are replaced with decimal digits, then Bicarp wins. Otherwise, Monocarp wins. You have to determine who will win if both players play optimally.

翻译中…

Input

翻译中…

The first line contains one even integer $n$ $(2 \le n \le 2 \cdot 10^{5})$ — the number of digits in the ticket.

翻译中…

The second line contains a string of $n$ digits and "?" characters — the ticket which Monocarp and Bicarp have found. If the $i$-th character is "?", then the $i$-th digit is erased. Note that there may be leading zeroes. The number of "?" characters is even.

翻译中…

Output

翻译中…

If Monocarp wins, print "Monocarp" (without quotes). Otherwise print "Bicarp" (without quotes).

翻译中…

Note

翻译中…

Since there is no question mark in the ticket in the first example, the winner is determined before the game even starts, and it is Bicarp.

翻译中…

In the second example, Bicarp also wins. After Monocarp chooses an erased digit and replaces it with a new one, Bicap can choose another position with an erased digit and replace it with the same digit, so the ticket is happy.

翻译中…

样例

Input #1
4
0523
Output #1
Bicarp
InputCopy OutputCopy
Input #2
2
??
Output #2
Bicarp
InputCopy OutputCopy
Input #3
8
?054??0?
Output #3
Bicarp
InputCopy OutputCopy
Input #4
6
???00?
Output #4
Monocarp
InputCopy OutputCopy
题目信息
题号
1215D
时间限制
1 s
内存限制
256 MB
标签
博弈论
贪心
数学

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。