F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

dingyeye loves stone

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 695    Accepted Submission(s): 378


Problem Description
dingyeye loves play stone game with you.

dingyeye has an $n$-point tree.The nodes are numbered from $0$ to $n-1$,while the root is numbered $0$.Initially,there are $a[i]$ stones on the $i$-th node.The game is in turns.When one move,he can choose a node and move some(this number cannot be $0$) of the stones on it to its father.One loses the game if he can't do anything when he moves.

You always move first.You want to know whether you can win the game if you play optimally.
 

Input
In the first line, there is an integer $T$ indicating the number of test cases.

In each test case,the first line contains one integer $n$ refers to the number of nodes.

The next line contains $n-1$ integers $fa[1]\cdots fa[n-1]$,which describe the father of nodes $1\cdots n-1$(node $0$ is the root).It is guaranteed that $0\leq fa[i]< i$.

The next line contains $n$ integers $a[0]\cdots a[n-1]$,which describe the initial stones on each nodes.It is guaranteed that $0\leq a[i]<134217728$.

$1\leq T\leq 100$,$1\leq n\leq 100000$.

It is guaranteed that there is at most $7$ test cases such that $n>100$.
 

Output
For each test case output one line.If you can win the game,print "win".Ohterwise,print "lose".
 

Sample Input
2 2 0 1000 1 4 0 1 0 2 3 3 3
 

Sample Output
win lose
 

Source
 

Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2024 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2024-05-02 21:52:49, Gzip enabled