#P1839. Play with Power

Play with Power

Description

Masha and Stas are playing a game. At the start of the game, a number nn is given, along with two positive integers a,ba, b, which initially satisfy abna^b \le n.

Masha moves first. On each turn, a player must increase exactly one of aa or bb by 11, but may not make ab>na^b > n; otherwise that player loses.

Now Masha wants to know, if both players play optimally, for the same nn and different a,ba, b, who will win.

Input Format

The first line contains a number nn.

The second line contains a number tt, the number of test cases.

The next tt lines each contain two numbers a,ba, b, describing each test case.

Output Format

Output tt lines, one for each test case:

  • If Masha wins, output Masha.
  • If Stas wins, output Stas.
  • If it is a draw, output Missing.
9 
2 
2  2 
1  4 
Masha 
Missing

Hint

Constraints

  • For 30% of the testdata, 1n2×1031 \le n \le 2 \times 10^3.
  • For 100% of the testdata, 1n1081 \le n \le 10^8, 1t1001 \le t \le 100, 1a,b,abn1 \le a, b, a^b \le n.

Translated by ChatGPT 5