PPR - Pizza Prize

Asad,Foyj,Juwel,Mijan,Tanmay are friends from group "Mission Starts".They are in the queue for Pizza in a bakery. No other people is in the queue. A person who takes one pizza can get two chances to get pizza at the end of queue.


Initial Chances queue: Asad, Foyj, Juwel, Mijan, Tanmay .

After taking 1st pizza the Chances queue: Foyj, Juwel, Mijan, Tanmay, Asad, Asad.

After taking 2nd pizza the Chances queue: Juwel, Mijan, Tanmay, Asad, Asad, Foyj, Foyj.

And So on……..

But the shopkeeper wants to offer a special prize to a person who have the N th pizza.In this case, He asks for your help. You are a great programmer in our country. Your task is to find the name of the lucky winner who have the N th pizza(the queue only contain these 5 peoples and their order should be maintained strictly).


Every line of the input contains a single integer N denoting the lucky pizza number.


  • 1 ≤ N ≤ 109


For each test case, print a single line and print the name of the lucky winner.



hide comments
nadstratosfer: 2018-07-01 12:12:10

Every item popped from the front of the queue gets added twice at the end. Write a simulation and see what happens!

prajjyadv0904: 2018-06-28 20:26:15

can anyone explain what will happen after third time will he get 3 chances or 4 chances or only 2 chances?

shravinson: 2018-06-28 07:18:24

silly calculation mistake cause me 1 WA.....
nice problem........

code_aim: 2018-06-25 15:03:28

At least the problem setter should clearly mention about the input format.
For all others please read the input to end of file.

manishjha221: 2018-06-25 13:23:04

guys pls tell for the third time Asad will get 3 pizza and fourth time four || third time 4 and fourth time 8 and so on.............

tusharjape: 2018-06-25 13:09:13

@asad_IT please make it clear in the input format to read input until end of file. The current explanation seems dubious.

prakash1108: 2018-06-24 21:30:08

spelling mistake cause me 1WA :(

n_o_o_b_i_e: 2018-06-24 18:22:13

don't know why it shows WA

prateek_imkp1: 2018-06-24 17:57:03

Nice question . But please specify the input format .

Last edit: 2018-06-26 11:33:12
syamphanindra: 2018-06-24 16:36:40

Hey input format is correct??

Added by:asad_IT
Time limit:0.5s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)