Dangerous Divisor


Submit solution

Points: 1
Time limit: 1.5s
Memory limit: 256M

Problem type
Allowed languages
C, C++, Java, Python

Jamie and Marcus are playing a game to determine who gets a free ACPC T-Shirt. Ritisha has provided them an integer n, and they repeatedly take turns altering the number according to certain rules. The player who is unable to move loses (i.e. when n is 1).

On a given turn, the player must:

  • Chose a proper divisor d of n, i.e. 1 \leq d < n,d\mid n
  • Replace n with n-d

Surprisingly, both Jamie and Marcus are playing the game optimally. Jamie always goes first, and Marcus second. For a given n, determine if Jamie or Marcus will win.

Input

A single integer n (1 \leq n \leq 10^9)

Output

Output the person who will win if both play optimally and the person who is unable to move loses (i.e. when n=1). Jamie goes first and Marcus goes second.

Example

Input 1
5
Output 1
Marcus
  • First, Jamie must subtract 1 as it is the only proper divisor: n=4
  • Next, Marcus can either subtract 2 or 1. If he subtracts, 2, Jamie will subtract 1 and win, so Marcus subtracts 1. n=3.
  • Jamie can only subtract 1. n=2.
  • Marcus subtracts 1. Now n=1 so Jamie has no option and Marcus wins.
Input 2
1
Output 2
Marcus

Jamie instantly loses. Classic Jamie.

Input 3
10
Output 2
Jamie

There are a number of ways the game can go but Jamie can always force a win.


Comments

There are no comments at the moment.