This page is still under construction.

Parts of this page are still being built. What you see may change.

Game

Time limit0.1sMemory limit1024 MB

Summary
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 AA and BB. Assume A≤BA \le B. The players take turns, and on a turn a player makes one of these two moves.

  • Replace BB with B−AKB-AK. The player can pick any integer KK with K>0K>0 and B−AK≥0B-AK \ge 0.
  • Replace BB with B mod AB \bmod A.

If B≤AB \le A, the same moves are available with the roles of the two numbers swapped. The player who turns either number into 00 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 TT (1≤T≤1041 \le T \le 10^4). Each of the next TT lines describes one game and contains two integers AA and BB (1≤A,B≤10181 \le A, B \le 10^{18}).

Output

Print TT lines. Line ii contains the name of the winner of the ii-th game, either Mirek or Kamil.

Examples2

  1. Example 1

    Input
    4
    1 1
    12 4
    4 6
    15 31
    
    Expected output
    Mirek
    Mirek
    Kamil
    Mirek
    
  2. Example 2

    Input
    1
    2 3
    
    Expected output
    Kamil