Under construction

Still being built. Things may change

Malvika and Animesh play Red-Blue Card Game

Time limit1sMemory limit1024 MB

Summary
Given a row of R and B cards, two players alternately flip a red card and any run of blue cards to its right. Find the winner under optimal play.
Level

Medium6 of 10

Topics
Game theory, Bit manipulation
Solved
No attempts yet

Problem

Malvika and Animesh play a game with nn cards in a row, from left to right. Each card is red on one side and blue on the other. Malvika moves first, and the players alternate turns.

On a turn, the player chooses a card that is red face up. The player also chooses zero or more consecutive blue face up cards immediately to the right of the chosen card. All chosen cards are flipped: the red card becomes blue, and the chosen blue cards become red. The turn then passes to the other player.

The player who cannot make a move on their turn loses. Both players play optimally. Find the winner.

Input

The first line contains a single integer TT, the number of test cases.

Each test case is a single line containing a string of 'R' and 'B' characters. The i-th character is the initial face of the i-th card from the left, where 'R' means red face up and 'B' means blue face up.

Output

For each test case, print one line: 'Malvika' if Malvika wins, or 'Animesh' if Animesh wins.

Constraints

1≤T≤1001 \le T \le 100

1≤n≤5001 \le n \le 500, where nn is the length of each string.

Hint

In the first example, Malvika flips the red card on her first move, so it becomes blue. Animesh then has no move and loses, so Malvika wins.

In the second example, Malvika has no move on her first turn, so she loses and Animesh wins.

Examples1

  1. Example 1

    Input
    2
    R
    BB
    
    Expected output
    Malvika
    Animesh