Mojo, Jojo and Game
Tag(s):

## Algorithms, Easy-Medium

Problem
Editorial
Analytics

After solving some programming problems, Mojo and Jojo want to take some time off and play some game. They ask Rhezo what to play. Rhezo tells them about a game with the following rules:

There are N stacks of coins, each containing X coins. Both players take turns, with Mojo moving first. The only allowed moves are the following:

1. Remove any stack of coin.

2. Remove any 2 stacks.

3. Remove $X/2$ coins from each stack if X is even, or remove $(X+1)/2$ coins from each pile, if X is odd.

The game finishes when there are no more coins left in any stack. The last person to make the move wins. Both, Mojo and Jojo play optimally and want to win. Can you tell who will win this game?

Input:

First line of the input contains an integer T, denoting the number of test cases you have to handle.
Each test case consists of two integers, N and X, separated by a single space.

Output:

For each test case, if Mojo wins, print "Mojo", else print "Jojo" (quotes only for clarity).

Constraints:

• $1 \le T \le 10^3$
• $1 \le N \le 10^3$
• $1 \le X \le 10^9$

SAMPLE INPUT
1
4 5
SAMPLE OUTPUT
Jojo

Explanation

One possible flow of the game is as follows:

$\bullet$ There are 4 stacks with 5 coins each, Mojo removes 2 stacks.

$\bullet$ There are 2 stacks left now with 5 coins each, Jojo removes 2 stacks, and wins.

We can show that for any possible flow of the game, Jojo will always win.

Time Limit: 1.0 sec(s) for each input file.
Memory Limit: 256 MB
Source Limit: 1024 KB
Marking Scheme: Marks are awarded when all the testcases pass.
Allowed Languages: Bash, C, C++, C++14, Clojure, C#, D, Erlang, F#, Go, Groovy, Haskell, Java, Java 8, JavaScript(Rhino), JavaScript(Node.js), TypeScript, Julia, Kotlin, Lisp, Lisp (SBCL), Lua, Objective-C, OCaml, Octave, Pascal, Perl, PHP, Python, Python 3, R(RScript), Racket, Ruby, Rust, Scala, Swift, Swift-4.1, Visual Basic

## CODE EDITOR

Initializing Code Editor...

## This Problem was Asked in Challenge Name

December Easy '16

OTHER PROBLEMS OF THIS CHALLENGE
• Basic Programming > Implementation
• Basic Programming > Implementation
• Algorithms > Dynamic Programming
• Data Structures > Advanced Data Structures
• Data Structures > Advanced Data Structures