MAIN73 - Manoj and Pankaj

no tags 

Manoj and Pankaj play the following game on a N×M grid, Each cell of which is either empty or contain a stone.

Each player in his his turn must take one of the two moves described below:-

  1. He can shift an stone to its adjacent right cell, if that cell is empty.
  2. He can remove a stone completely from the grid.

The first player who is unable to take a move looses the game. It is also given that both the players will play optimally and Manoj always take the first turn.

You have to find who will win the game. 

Input

First line of each test case contains two integers N and M. (1<=N, M<=200) Each of next N lines contains an string, jth character on of ith string is '*' if there is an stone otherwise it is '.' (empty). Input ends when N, M = 0, 0. which is not to be processed.

Output

For each test case print 'Manoj' if Manoj wins, print 'Pankaj' otherwise.

Example

Input:
2 2
.*
.*

2 2
.*
*.
0 0

Output:
Pankaj
Manoj

hide comments
Mahesh Chandra Sharma: 2011-05-19 14:21:53

@V0iD! Manoj will shift the lower stone to right then Pankaj will have no choice other than removing an stone then in the 3rd move Manoj will also remove an stone and wins!

V0iD!: 2011-05-05 16:48:24

In the second test case, if Manoj removes a stone, followed by Pankaj removing a stone, Manoj loses, right?? Or am I missing something?

Jayesh: 2011-03-21 08:45:22

can be removed during any time

Anant Sharma: 2011-03-21 06:05:28

Can a stone be removed only after it has reached the right end or during anytime of the game?


Added by:Mahesh Chandra Sharma
Date:2011-03-13
Time limit:1s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: ASM64
Resource:Own problem used for NSIT-IIITA main contest #7