Sphere Online Judge

Computer geeks! Show off your skills and claim the job of your dreams! RecruitCoders.com

SPOJ Problem Set (classical)

1028. Hubulullu

Problem code: HUBULLU

After duelling in quake (a multiplayer game), Airborne and Pagfloyd decide do test themselves out in another game called Hubulullu. The rules of the game are as follows:

N wooden pieces (marked with numbers 1 to N) are placed in a transparent bottle. On his turn the first player takes out some piece (numbered x) and all the pieces numbered by divisors of x that are present in the transparent bottle. The second player picks another number and removes it and its divisors as well. Play continues in an alternating fashion until all pieces have been removed from the bottle. The player who removes the last piece from the bottle wins the game.

Both players play optimally. Given N (the number of wooden pieces in the transparent bottle initially) and the name of the player who starts the game, determine the winner.

Input

The first line of the input contains an integer t, the number of test cases. t test cases follow.

Each test case consists of a single line containing two integers separated by a single space. The first integer is N (1 <= N <= 2000000000), indicating the number of pieces, and the second integer indicates the player who starts - "0" means Airborne starts the game and "1" means Pagfloyd starts the game (quotes for clarity).

Output

For each test case output one line containing either "Airborne wins." or "Pagfloyd wins."

For each N, it's possible to determine a winner if both players play optimally.

Example

Input:
1
1 0

Output:
Airborne wins.

Added by:Matthew Reeder
Date:2006-10-29
Time limit:7s
Source limit:30000B
Languages:All except: ERL JS PERL 6
Resource:Al-Khawarizm 2006

hide comments
2012-05-14 11:32:52 Archana Anand
damn easy ...nothin to code in this!!!
2012-03-22 04:25:14 Sandy Akbar Dewangga
funny indeed :)
2012-02-08 13:26:40 Dheeraj Kumar
is 1 considered as divisor of every no. ???
2012-02-08 13:26:40 Dheeraj Kumar
is 1 considered as divisor of every no. ???
2012-01-14 10:03:18 saket diwakar
after understanding this...i found it as the easiest question ever on spoj.....
2011-12-29 13:07:23 Devil D
Simplest Logic possible .. Just analyse :)
2011-06-11 22:20:39 Gaurav
this is not good.....by reading comments on observation thing i focussed more on that....and didint look for a better logic...
2011-06-07 21:11:04 KAPIL
can anyone give me more test cases.
2011-05-27 15:59:15 ~
very funny..........every thing on observation.......:)
2011-04-15 12:26:30 Radek
funny...
SPOJ System © 2012 Sphere Research Labs | Projekty informatyczne i aplikacje na zamówienie. All Rights Reserved.