#P1839. Masha and Stas Game
Masha and Stas Game
Masha and Stas Game
Two players, Masha and Stas, play the following game. You are given a positive integer \(n\) and two positive integers \(a\) and \(b\) such that \(a^b \le n\). Masha moves first. On each turn a player must increase exactly one of the numbers \(a\) or \(b\) by 1. However, after the increment the new pair \((a, b)\) must still satisfy \(a^b \le n\). If a player is forced to make a move that would result in \(a^b > n\), that player loses.
Assuming both players use optimal strategies, determine which player will win for the given values of \(n\), \(a\), and \(b\).
Note: A state \((a, b)\) is terminal if neither incrementing \(a\) nor \(b\) yields a state with \(a^b \le n\); the player forced to move in a terminal state loses.
inputFormat
The input consists of three space‐separated integers: (n), (a), and (b) (with the condition (a^b \le n)).
outputFormat
Output a single line: print "Masha" if the first player (Masha) wins under optimal play, otherwise print "Stas".
sample
4 2 1
Masha