BGC TRUST IUPC 2012

 

Problem F

I am Dumb 3

 

 

You know very well that I am dumb, I am too dumb. So here goes the thing I have learnt today. Given n axis parallel rectangles in a plane, how will you find the area of their intersection? Hmm.. well, I think this is solvable by Segment Tree data structure.. uhh.. finally I can solve a segment tree problem. So I jumped to code. Code, debug, code, debug … and like this 5 hours passed. And what? I could not solve it again! Again we are returning home empty handed. We were sad, sitting at our desk. Sultan Mahmud came laughing (you know him right? He is all time champ, and won the contest today again), “hey little genius, what happened today? Why no solve?” We said, “Oh Sultan Mahmud, what can we do? We knew segment tree, but could not finish debugging, what can we do?” Sultan Mahmud raising his eye brows- “Segment tree? Which one?” When we showed him the problem he busted into laugh, “Actually you know too much, think it without segment tree”. Then my team mate says, uhh.. now I see… this one is so simple! You take the rightmost left edge and leftmost right edge of all the rectangles. Similarly the bottom and top edge. If they form a valid rectangle then that will be the answer rectangle. I could not get the solution because I am dumb. But I think you are smarter than me. I hope you already figured it out how to solve the problem in O(n) time. If not then think it after the contest.

 

Anyway, on the way back home I was thinking- who wants to be a millionaire? Everyone. But who wants to be a dumb? No one! So to shake off the label “dumb” I went to Sultan Mahmud to challenge him at any game of his wish. But I found him crying at floor throwing his hands and legs. I hurried to him, “Hey hey what happened! You are crying even after winning the contest?”. Sultan Mahmud said, “What can happen? Nothing!! just half of my treasure is empty!” and he started to cry again. I called his Ujir and gave him order to find the thief, but Sultan Mahmud instead said, “No no, you don’t need to find, you go from here” and the Ujir left. I wondered- what happened to Sultan! Then he told me, “I myself spent half of my treasure within an hour” “WHAT!!! How could you spend half of the treasure!! And only within an hour!!!” Sultan sighed and said, “Princess of Ainorfalic came and she wanted to buy me a watch, so I took her to shopping and …” and he started to cry again. I said, “Ah.. that’s possible” anyway, I thought it is the best chance to win over Sultan Mahmud in this mental situation, so I challenged him for any game of Sultan’s choice. Sultan jumped off his sad face and started to describe the game, “There will be n piles of coins in a line. Number of coins in the first pile will be less or equal to the number of coins in the second pile, number of coins in the second pile will be less or equal to the number of coins in the third pile and so on. And the number of coins in the last pile can be at most L. You can add any number of coins at any pile but you have to maintain all the conditions I specified. The number of coins in each pile is given initially. He who won’t be able to make a move will lose. And as an honor you will give the first move.” And guess what, I lost again!!! I am Dumb! Can you help me? If I give you the initial configuration of coins, can you tell me who should win if both play optimally? First player or second player? (Please note that, at any position of the game, the coin piles have to maintain the “less-equal” constraint and the last pile can be of at most L size)

Input

 

In the first line there will be number of test case (at most 100). In the first line of every test case there will be n the number of piles (at least 1 and at most 50) and the highest limit L (at most 1,000,000). The following line will contain N numbers in non-decreasing order.

 

 

Output

 

For each test case output the case number, followed by “First Player” or “Second Player” where they are appropriate.

 

 

Sample Input

Output for Sample Input

2

2 13

9 10

2 6

2 2

Case 1: First Player

Case 2: Second Player

 

 

 

Problemsetter: Md. Mahbubul Hasan

Special Thanks: Jane Alam Jan