Pinely Round 2 (Div. 1 + Div. 2)
A
Channel
Codeforces
800
原题
←B →
翻译中…

Petya is an administrator of a channel in one of the messengers. A total of $n$ people are subscribed to his channel, and Petya is not considered a subscriber.

翻译中…

Petya has published a new post on the channel. At the moment of the publication, there were $a$ subscribers online. We assume that every subscriber always reads all posts in the channel if they are online.

翻译中…

After this, Petya starts monitoring the number of subscribers online. He consecutively receives $q$ notifications of the form "a subscriber went offline" or "a subscriber went online". Petya does not know which exact subscriber goes online or offline. It is guaranteed that such a sequence of notifications could have indeed been received.

翻译中…

Petya wonders if all of his subscribers have read the new post. Help him by determining one of the following:

翻译中…
  • it is impossible that all $n$ subscribers have read the post;
  • it is possible that all $n$ subscribers have read the post;
  • it is guaranteed that all $n$ subscribers have read the post.
翻译中…

Input

翻译中…

Each test contains multiple test cases. The first line contains the number of test cases $t$ ($1 \le t \le 500$). The description of the test cases follows.

翻译中…

The first line of each test case contains three integers $n$, $a$, and $q$ ($1 \le n \le 100$, $0 \le a \le n$, $1 \le q \le 100$) — the number of subscribers of the channel, the initial number of subscribers online, and the number of notifications.

翻译中…

The second line of each test case contains a string of length $q$, consisting of characters '+' and '-'. The $i$-th of these characters is '+', if the $i$-th notification tells that a subscriber goes online, and it is '-' otherwise.

翻译中…

Output

翻译中…

For each test case, output a single line: "YES" if all $n$ subscribers are guaranteed to have read the post, "NO" if it is impossible for all $n$ subscribers to have read the post, and "MAYBE" otherwise.

翻译中…

Note

翻译中…

In the first test case, there are $5$ out of $5$ subscribers online in the very beginning, so they will all read the post no matter what. The answer is "YES".

翻译中…

In the second test case, the number of subscribers online becomes $4$ after the first two notifications, next someone goes offline, and thus the fifth subscriber has no chance of reading the post. It is impossible for all the subscribers to read the post, so the answer is "NO".

翻译中…

In the third test case, on the one hand, the same person may have gone offline and online (in this case only $4$ out of $5$ subscribers have read the post), on the other hand, the last notification may have told that the fifth subscriber has gone online (in this case all subscribers have read the post). We cannot deduce which of the two holds, so the answer is "MAYBE".

翻译中…

In the fourth test case, there have to be five subscribers online after all the notifications. All of them will read the post, so the answer is "YES".

翻译中…

样例

Input #1
4
5 5 3
--+
5 2 3
++-
5 4 2
-+
5 0 7
++++-++
Output #1
YES
NO
MAYBE
YES
InputCopy OutputCopy
题目信息
题号
1863A
时间限制
1 s
内存限制
256 MB
标签
贪心
模拟

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