Welcome to ZOJ
Information
Problems
Runs
Statistics
Ranklist
Clarification
101 - ZOJ Monthly, December 2010 - G
Doraemon's Stone Game

Time Limit: 2 Seconds      Memory Limit: 65536 KB

Doraemon is playing a game with Dorami. Initially there are piles of stones on the table. Each pile consists of at most 2 stones. Each stone may be black or white. Doraemon and Dorami take turn to take away the stones, the rule is as follows:

  • Doraemon can only take away a white stone each time.
  • Dorami can only take away a black stone each time.
  • If the stone in the bottom is taken away, the whole pile is removed.
  • The first one who can't take away any stone lose. The other one is the winner

Now the piles of stones on the table are known, Doraemon wants to know if he can win. Can you help him?

Input

There are multiple cases (about 45000).
For each case, the first line is an integer N (1 ≤ N ≤ 6). Then N lines follows. The i-th line contains a string Si and an integer number ai (1 ≤ ai ≤ 1000000000). Si represents a pile of stones. The characters from left to right correspond to stones from top to bottom. The character 'w' means that stone is white and 'b' means that stone is black. The integer ai means there are ai piles of stones represented by Si. It's guaranteed that SiSj when ij.

Output

For each case, output two words separated by a space in one line. The first word should be "win" if Doraemon can win the game if he makes move first, otherwise it should be "lose". The second word should be "win" if Doraemon can win the game if Dorami makes move first, otherwise it should be "lose".

Sample Input

 
2
w 1
b 1
2
b 1
wb 1

Sample Output

 
lose win
lose lose

Author: ZHOU, Yilun
Contest: ZOJ Monthly, December 2010
Submit    Status