MESS WORKERS' GAME

0

0 votes
Problem

The mess workers get bored between the lunch-hour and the dinner-hour period. They have come up with a game which they can play while doing their utensil cleaning and arrangement process to spice up their jobs.

They have N shelves, labeled 0 to N-1 on which the plates are stacked. There are P number of plates, which are stacked on the shelves such that any shelf can initially have any number of plates (0 or 1 or more). By the lunch/dinner-time, they have to shift all the plates to the shelf labeled 0 which is closest to the serving counters. They design a game, which they will play in order to accomplish this rearrangement of plates.

Two workers play this game which consists of alternate moves. A move consists of removing any one plate off any shelf and moving it to any shelf strictly to its left. The destination shelf can be empty prior to this shifting or may already contain one or more plates. The workers alternate moves and the game ends when all the plates have been stacked on the shelf labeled 0 (and hence, their job is over!). The last worker to move wins (i.e. the worker which can't make a move looses). BOTH THE WORKERS WANT TO WIN AND HENCE PLAY OPTIMALLY.

Given the initial configuration of the plates on the shelves, determine who wins the game. (WORKER1 moves first)

INPUT:

The first line of the input contains an integer T denoting the number of test cases. The description of T test cases follows. Each case start with a line containing two space separated integers N and P, denoting the number of shelves and plates respectively. This is followed by a line (describing the initial configuration) containing N space separated integers A[i], where A[i] represents the number of plates stacked on the shelf labeled i.

OUTPUT:

For each test case, output a single line containing the name of the winner, i.e. "WORKER1" or "WORKER2" [without quotes].

CONSTRAINTS:

1 <= T <= 10^4

1 <= N <= 100

0 <= P <= 10^15

PROBLEM SETTER: Shobhit Chaurasia

Time Limit: 2
Memory Limit: 256
Source Limit:
Editor Image

?