F

Game

Input: Standard Input

Output: Standard Output

 

 

Alice and Bob are playing a 2 player game. The game has the following rules.

  • It consists of 2 stone piles containing a and b number of stones.
  • In each turn a player can take stones from a single pile or both pile. If she takes stones from 1 pile then she can take up to all the stones from that pile. If she wants to take stones from both piles than the absolute difference between the number of stones taken from each pile can be at most k. In both cases she should take at least one stone.
  • The player who takes the last stones wins.

 

You are given the information about the game. Alice is the first player. You have to determine whether she will win or lose.

 

Input

First line of the input contains T (1≤T≤10) the number of test case. Then following lines contains T Test cases.

 

Each case starts with line containing 2 integers k (1≤k≤20) and q (1≤q≤10000). Each of the next q lines will contains 2 integers a and b (1≤a,b≤100000). Each of these a and b pair along with the initial k will be instance of a game.

 

Output

For each game output will be a single line containing a stringing “WINNING” if Alice can win that game or “LOSING” if she can not win that game. Output a blank line after each test case.

 

 

Sample Input                            Output for Sample Input

1

1 4

2 5

2 6

1 3

1 4

 

WINNING

LOSING

LOSING

WINNING

 


Problemsetter: Abdullah al Mahmood

Special Thanks: Derek Kisman