Vasya was performing big laboratory work in "Spelling and parts of speech" at night before the game, so he fell asleep at the very beginning of the game. Petya decided to take the advantage of this situation and make both Petya's and Vasya's moves.
Your task is to help Petya find out if he can win the game or at least draw a tie.
The first line of input contain two integers n and m — the number of vertices and the number of edges in the graph (2 ≤ n ≤ 105, 0 ≤ m ≤ 2·105).
The next n lines contain the information about edges of the graph. i-th line (1 ≤ i ≤ n) contains nonnegative integer ci — number of vertices such that there is an edge from i to these vertices and ci distinct integers ai, j — indices of these vertices (1 ≤ ai, j ≤ n, ai, j ≠ i).
It is guaranteed that the total sum of ci equals to m.
The next line contains index of vertex s — the initial position of the chip (1 ≤ s ≤ n).
If Petya can win print «Win» in the first line. In the next line print numbers v1, v2, ..., vk (1 ≤ k ≤ 106) — the sequence of vertices Petya should visit for the winning. Vertex v1 should coincide with s. For i = 1... k - 1 there should be an edge from vi to vi + 1 in the graph. There must be no possible move from vertex vk. The sequence should be such that Petya wins the game.
If Petya can't win but can draw a tie, print «Draw» in the only line. Otherwise print «Lose».
5 6
2 2 3
2 4 5
1 4
1 5
0
1
Win
1 2 4 5
3 2
1 3
1 1
0
2
Lose
2 2
1 2
1 1
1
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <string>
#include <algorithm>
#include <cmath>
#include<map>
#include<vector>
#define qq printf("QAQ\n");
#define ll long long
#define p(num) printf("%d\n",num);
using namespace std;
const int maxn=1e5+5;
const int mod=1e9+7;
const int inf=1e9;
vector<int>v[maxn];
int use1[maxn][2],use2[maxn];
int a[1000005],f;
void dfs(int st,int num)
{
if(num>=1000000)return ;
a[num]=st;
use1[st][num%2]=1;
if(!v[st].size()&&num%2==0){
printf("Win\n");
for(int i=1;i<=num;i++)
if(i!=1)printf(" %d",a[i]);
else printf("%d",a[i]);
f=1;
printf("\n");
exit(0);///找到路了直接退出
// return ;
}
for(int i=0;i<v[st].size();i++)
{
//if(f==1)return ;
int en=v[st][i];
if(use2[en])f=2;
if(use1[en][(num+1)%2])continue;//记录是否走重的路(单双数来标记)
use2[en]=1;//记录是否成环,
dfs(en,num+1);
use2[en]=0;
}
}
int main()
{
int n,m,st,en,x;
scanf("%d%d",&n,&m);
for(int i=1;i<=n;i++)
{
scanf("%d",&x);
for(int j=1;j<=x;j++){
scanf("%d",&en);
v[i].push_back(en);//存边
}
}
scanf("%d",&st);
f=0;
use2[st]=1;
dfs(st,1);
if(f==0)printf("Lose\n");
if(f==2)printf("Draw\n");
return 0;
}