Game
Time limit0.1sMemory limit1024 MB
For each pair of positive integers A and B, decide who wins a subtraction game where a player may subtract any positive multiple of the smaller number from the larger, or take the remainder modulo the smaller.
- Level
Medium7 of 10
- Topics
- Game theory, Math
- Solved
- No attempts yet
Problem
Mirek likes playing with numbers. He plays the following game with his friend Kamil.
A game starts with two non-negative integers and . Assume . The players take turns, and on a turn a player makes one of these two moves.
- Replace with . The player can pick any integer with and .
- Replace with .
If , the same moves are available with the roles of the two numbers swapped. The player who turns either number into wins. Mirek always moves first.
Both players play optimally. For each game, determine whether Mirek or Kamil wins.
Input
The first line contains the number of games (). Each of the next lines describes one game and contains two integers and ().
Output
Print lines. Line contains the name of the winner of the -th game, either Mirek or Kamil.