STRGAMB - Street Gambler

no tags 

Madrid is a tremendously historic and monumental city that attracts several millions of visitors each year. Where there are tourists, there are also artists that entertain the crowds in the streets and gamblers that challenge pedestrians to often snaky games. One of them is just about to ask you for a game. Although you learned in problem X some basics of Spanish conjugation, you are not proficient enough to understand the rules of the game. This is why you decide to observe first some games, from which you succeeded to extract the rules correctly:

1 2 3 4 5 6 7 8
    O   O O O O


Here are the turns you observed for the initial game constellation of the above figure:

XXOXOOOO                Tourist empties 7 and puts a coin in 4
XXOOOOXO                Gambler empties 8 as well as 4
XXOXOOXX                Tourist empties 6 and puts a coin in 1
OXOXOXXX                Gambler empties 5 and puts a coin in 2
OOOXXXXX                Tourist empties 1
XOOXXXXX                Gambler empties 3 as well as 2
XXXXXXXX                Tourist lost the game, as no coin is left

You are a bit surprised that the gambler wins most of the games. He must indeed have several years of experience and know some tricks. As you are smart, you discover his trick. Supposing that both of you play optimally, that is, once you are in a winning constellation, you’ll find the correct moves to win the game, can you tell for a given constellation whether you should make the first move or leave it to the gambler? Of course you want to win!

Input

The input consists of several test cases (T ≤ 300), one per line that describes the initial board constellation as a string of ‘O’s and ‘X’s. Read from left to right, this string describes the board constellation from position 1 to position N (N ≤ 255). ‘O’ stands for a square with coin, ‘X’ for an empty square. The input terminates on the string “end” that should obviously not be processed.

Output

Output “I’d like to play first” or “After you”, so that you will win the game.

Example

Input:
XXOOOX
OOOXX
XOOOOOOOO
XXXXOXXXXXXXOXOXXXXXXOXXXXXXXXX
end

Output:
I'd like to play first
After you
After you
I'd like to play first

hide comments
Mateusz Koz³owski: 2011-05-09 16:28:04

Hallo! My time on ideone is 0,01 s for maximum input (about 500 lines) and I still get TLE. Is everything ok with this task?


Added by:Christian Kauth
Date:2009-10-17
Time limit:6.666s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: ERL NODEJS OBJC PERL6 VB.NET