#include<iostream>
#include<iomanip>
#include<string>
#include<time.h>
#include<algorithm>
#include<queue>
#include<stack>
#include<list>
#include<vector>
#include<set>
#include<map>
#include<math.h>
#include<utility>
#define ll long long
#define endl "\n"
#define FIO ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using namespace std;

vector<vector<ll>>dp[1000];

void solve() {
    ll n, k, M = 998244353;
    cin >> n >> k;
    for(int i = 0; i < n; ++i) {
        dp[i] = vector<vector<ll>>(4, vector<ll>(2006, 0));
    }
    for(int i = 0; i < n; ++i)
        for(auto &it : dp[i])
            for(auto &jt : it)
                jt = 0;
    // 0 ww 1 wb 2 bw 3 bb
    int get[4][4] = {{0, 1, 1, 1}, {0, 0, 2, 0}, {0, 2, 0, 0}, {1, 1, 1, 0}};
    for(int i = 0; i < n; ++i) {
        if(!i) {
            dp[0][0][1] = 1;
            dp[0][1][2] = 1;
            dp[0][2][2] = 1;
            dp[0][3][1] = 1;
        }
        else {
            for(int j = 1; j < k + 1; ++j) {
                for(int it = 0; it < 4; ++it)
                    for(int jt = 0; jt < 4; ++jt) {
                        dp[i][jt][j+get[it][jt]]=(dp[i][jt][j+get[it][jt]] + dp[i-1][it][j]) % M;
                    }
            }
        }
    }
    cout << (dp[n - 1][0][k] + dp[n - 1][1][k] + dp[n - 1][2][k] + dp[n - 1][3][k]) % M;
}
int main() {
    FIO;
    //freopen("input.txt", "r", stdin);
    int t = 1;
    //cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}


#include<iostream>
#include<iomanip>
#include<string>
#include<time.h>
#include<algorithm>
#include<queue>
#include<stack>
#include<list>
#include<vector>
#include<set>
#include<map>
#include<math.h>
#include<utility>
#define ll long long
#define endl "\n"
#define FIO ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using namespace std;

vector<vector<int>>adj;
int n, k, ans = 1;
vector<bool>chk;

int travel(int u = 0) {
    chk[u] = 1;
    vector<int>get;
    get.push_back(0);
    for(auto &i : adj[u]) {
        if(!chk[i]) {
            int tmp = travel(i);
            get.push_back(tmp);
        }
    }
    sort(get.begin(), get.end());
    int i = get.size() - 1;
    while(get[i] + get[i - 1] > k) {
        ans++;
        i--;
    }
    int tmp = get[i];
    get.clear();
    return tmp + 1;
}
void solve() {
    cin >> n >> k;
    adj.resize(n);
    chk.resize(n, 0);
    for(int i = 1; i < n; ++i) {
        int u, v;
        cin >> u >> v;
        u--, v--;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }
    travel();
    cout << ans;
}
int main() {
    //FIO;
    //freopen("input.txt", "r", stdin);
    int t = 1;
    //cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}


#include<iostream>
#include<iomanip>
#include<string>
#include<time.h>
#include<algorithm>
#include<queue>
#include<stack>
#include<list>
#include<vector>
#include<set>
#include<map>
#include<math.h>
#include<utility>
#define ll long long
#define endl "\n"
#define FIO ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using namespace std;

vector<vector<int>>dp[1000];

void solve() {
    ll n, k, M = 998244353;
    cin >> n >> k;
    for(int i = 0; i < n; ++i) {
        dp[i] = vector<vector<int>>(4, vector<int>(2006, 0));
    }
    for(int i = 0; i < n; ++i)
        for(auto &it : dp[i])
            for(auto &jt : it)
                jt = 0;
    // 0 ww 1 wb 2 bw 3 bb
    int get[4][4] = {{0, 1, 1, 1}, {0, 0, 2, 0}, {0, 2, 0, 0}, {1, 1, 1, 0}};
    for(int i = 0; i < n; ++i) {
        if(!i) {
            dp[0][0][1] = 1;
            dp[0][1][2] = 1;
            dp[0][2][2] = 1;
            dp[0][3][1] = 1;
        }
        else {
            for(int j = 1; j < k + 1; ++j) {
                for(int it = 0; it < 4; ++it)
                    for(int jt = 0; jt < 4; ++jt) {
                        dp[i][jt][j + get[it][jt]] = (dp[i][jt][j + get[it][jt]] + dp[i - 1][it][j]) % M;
                    }
            }
        }
    }
    int ans = 0;
    for(int i = 0; i < 4; ++i)
        ans = (ans + dp[n - 1][i][k]) % M;
    cout << (dp[n - 1][0][k] + dp[n - 1][1][k] + dp[n - 1][2][k] + dp[n - 1][3][k]) % M;
}
int main() {
    FIO;
    //freopen("input.txt", "r", stdin);
    int t = 1;
    //cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}


#include <iostream>
#include <map>
#include <vector>

using namespace std;

const int moder = 998244353;

void update(long long& a, long long b)
{
    a = (a + b) % moder;
}

int main()
{
    unsigned n, k;
    cin >> n >> k;

    // dp[k][s]
    vector<vector<long long> > dp(k + 4, vector<long long>(0b100));
    vector<vector<long long> > ndp(k + 4, vector<long long>(0b100));
    dp[1][0b00] = 1;
    dp[1][0b11] = 1;
    dp[2][0b01] = 1;
    dp[2][0b10] = 1;

    for (int i = 2; i <= n; ++i)
    {
        for (int j = 1; j <= k; ++j)
        {
            // 0b00
            update(ndp[j + 0][0b00], dp[j][0b00]);
            update(ndp[j + 1][0b01], dp[j][0b00]);
            update(ndp[j + 1][0b10], dp[j][0b00]);
            update(ndp[j + 1][0b11], dp[j][0b00]);

            // 0b01
            update(ndp[j + 0][0b00], dp[j][0b01]);
            update(ndp[j + 0][0b01], dp[j][0b01]);
            update(ndp[j + 2][0b10], dp[j][0b01]);
            update(ndp[j + 0][0b11], dp[j][0b01]);

            // 0b10
            update(ndp[j + 0][0b00], dp[j][0b10]);
            update(ndp[j + 2][0b01], dp[j][0b10]);
            update(ndp[j + 0][0b10], dp[j][0b10]);
            update(ndp[j + 0][0b11], dp[j][0b10]);

            // 0b00
            update(ndp[j + 1][0b00], dp[j][0b00]);
            update(ndp[j + 1][0b01], dp[j][0b00]);
            update(ndp[j + 1][0b10], dp[j][0b00]);
            update(ndp[j + 0][0b11], dp[j][0b00]);

        }

        ndp.swap(dp);
        fill(ndp.begin(), ndp.end(), vector<long long>(4));
    }

    long long ans = 0;
    for (int i = 0; i < 4; ++i)
        ans += dp[k][i];

    cout << ans << "\n";
}


#include <iostream>
#include <map>
#include <vector>

using namespace std;

const long long moder = 998244353;

void update(long long& a, long long b)
{
    a = (a + b) % moder;
}

void print(vector<vector<long long> >& dp)
{
    for (vector<long long>& i: dp)
    {
        for (long long j: i)
            cout << j << " ";
        cout << endl;
    }
    cout << endl;
}

int main()
{
    unsigned n, k;
    cin >> n >> k;

    // dp[k][s]
    vector<vector<long long> > dp(k + 4, vector<long long>(0b100));
    vector<vector<long long> > ndp(k + 4, vector<long long>(0b100));
    dp[1][0b00] = 1;
    dp[1][0b11] = 1;
    dp[2][0b01] = 1;
    dp[2][0b10] = 1;

    print(dp);

    for (int i = 2; i <= n; ++i)
    {
        for (int j = 1; j <= k; ++j)
        {
            // 0b00
            update(ndp[j + 0][0b00], dp[j][0b00]);
            update(ndp[j + 1][0b01], dp[j][0b00]);
            update(ndp[j + 1][0b10], dp[j][0b00]);
            update(ndp[j + 1][0b11], dp[j][0b00]);

            // 0b01
            update(ndp[j + 0][0b00], dp[j][0b01]);
            update(ndp[j + 0][0b01], dp[j][0b01]);
            update(ndp[j + 2][0b10], dp[j][0b01]);
            update(ndp[j + 0][0b11], dp[j][0b01]);

            // 0b10
            update(ndp[j + 0][0b00], dp[j][0b10]);
            update(ndp[j + 2][0b01], dp[j][0b10]);
            update(ndp[j + 0][0b10], dp[j][0b10]);
            update(ndp[j + 0][0b11], dp[j][0b10]);

            // 0b00
            update(ndp[j + 1][0b00], dp[j][0b00]);
            update(ndp[j + 1][0b01], dp[j][0b00]);
            update(ndp[j + 1][0b10], dp[j][0b00]);
            update(ndp[j + 0][0b11], dp[j][0b00]);

        }

        ndp.swap(dp);
        fill(ndp.begin(), ndp.end(), vector<long long>(4));
        print(dp);
    }

    long long ans = 0;
    for (int i = 0; i < 4; ++i)
        update(ans, dp[k][i]);

    cout << ans << "\n";
}


#include <iostream>
#include <map>
#include <vector>

using namespace std;

const long long moder = 998244353;

void update(long long& a, long long b)
{
    a = (a + b) % moder;
}

int main()
{
    unsigned n, k;
    cin >> n >> k;

    // dp[k][s]
    vector<vector<long long> > dp(k + 4, vector<long long>(0b100));
    vector<vector<long long> > ndp(k + 4, vector<long long>(0b100));
    dp[1][0b00] = 1;
    dp[1][0b11] = 1;
    dp[2][0b01] = 1;
    dp[2][0b10] = 1;

    for (int i = 2; i <= n; ++i)
    {
        for (int j = 1; j <= k; ++j)
        {
            // 0b00
            update(ndp[j + 0][0b00], dp[j][0b00]);
            update(ndp[j + 1][0b01], dp[j][0b00]);
            update(ndp[j + 1][0b10], dp[j][0b00]);
            update(ndp[j + 1][0b11], dp[j][0b00]);

            // 0b01
            update(ndp[j + 0][0b00], dp[j][0b01]);
            update(ndp[j + 0][0b01], dp[j][0b01]);
            update(ndp[j + 2][0b10], dp[j][0b01]);
            update(ndp[j + 0][0b11], dp[j][0b01]);

            // 0b10
            update(ndp[j + 0][0b00], dp[j][0b10]);
            update(ndp[j + 2][0b01], dp[j][0b10]);
            update(ndp[j + 0][0b10], dp[j][0b10]);
            update(ndp[j + 0][0b11], dp[j][0b10]);

            // 0b00
            update(ndp[j + 1][0b00], dp[j][0b00]);
            update(ndp[j + 1][0b01], dp[j][0b00]);
            update(ndp[j + 1][0b10], dp[j][0b00]);
            update(ndp[j + 0][0b11], dp[j][0b00]);

        }

        ndp.swap(dp);
        fill(ndp.begin(), ndp.end(), vector<long long>(4));
    }

    long long ans = 0;
    for (int i = 0; i < 4; ++i)
        update(ans, dp[k][i]);

    cout << ans << "\n";
}


#include <bits/stdc++.h>

using namespace std;

#define forn(i, n) for(int i = 0; i < int(n); i++)

const int N = 1000 + 7;
const int MOD = 998244353;

int dp[N][2 * N][4];

int add(int a, int b){
	return (a + b) % MOD;
}

bool full(int mask){
	return (mask == 0 || mask == 3);
}

int get(int mask, int nmask){
	int cnt = __builtin_popcount(mask ^ nmask);
	if (cnt == 0) return 0;
	if (cnt == 2) return (full(mask) ? 1 : 2);
	return (full(mask) ? 0 : 1);
}

int main() {
	int n, k;
	scanf("%d%d", &n, &k);
	forn(i, 4)
		dp[1][0][i] = 1;

	for (int i = 1; i < n; ++i){
		forn(j, k + 1){
			forn(mask, 4){
				forn(nmask, 4){
					dp[i + 1][j + get(mask, nmask)][nmask] = add(dp[i + 1][j + get(mask, nmask)][nmask], dp[i][j][mask]);
				}
			}
		}
	}

	int ans = 0;
	forn(mask, 4){
		int nw = get(mask, mask ^ 3);
		if (k >= nw)
			ans = add(ans, dp[n][k - nw][mask]);
	}

	printf("%d\n", ans);
}


#include <bits/stdc++.h>

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds;

#if !ONLINE_JUDGE
#define debug
#endif

using namespace std;

/*******  All Required define Pre-Processors and typedef Constants *******/
#define mem(a, b) memset(a, (b), sizeof(a))
#define repd(i,k) for(int i=k;i>=0;i--)
#define rep(i,k) for(int i=0;i<k;i++)
#define repn(i,k1,k2) for(ll i=k1;i<k2;i++)
#define sz(x) (ll)(x).size()
#define ff first
#define ss second

#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define INF (int)1e9
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define ee6 (ll)1000001
#define ee5 (ll)100001

#define trav(a, v) for(auto& a : v)

#define tt ll t;cin>>t; while(t--)
typedef long long int ll;

typedef pair<ll, ll> pr;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef vector<pr> vpr;
typedef vector<vpr>vvpr;
typedef vector<vi> vvi;

//*X.find_by_order(2) element at index=2
//X.order_of_key(1) how many elements strictly less than 1

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag,
    tree_order_statistics_node_update>;

#ifdef debug
#define dbg(...) { cerr<<"[ "; dump(#__VA_ARGS__, __VA_ARGS__);}
#undef endl
template <typename Arg1,typename Arg2>
ostream& operator << (ostream& out, const pair<Arg1,Arg2> &x) {
    return out<<"("<<x.ff<<","<<x.ss<<")";
}

template <typename Arg1>
ostream& operator << (ostream& out, const vector<Arg1> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}

template <typename Arg1>
ostream& operator << (ostream& out, const set<Arg1> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}

template <typename Arg1,typename Arg2>
ostream& operator << (ostream& out, const map<Arg1,Arg2> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}

template <typename Arg1,typename Arg2>
ostream& operator << (ostream& out, const unordered_map<Arg1,Arg2> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}

template <typename Arg1>
void dump(const string name, Arg1&& arg1){
    cerr << name << " : " << arg1 << " ] " << endl;
}

template <typename Arg1, typename... Args>
void dump(const string names, Arg1&& arg1, Args&&... args){
    const string name = names.substr(0,names.find(','));
    cerr<<name<<" : "<<arg1<<" | ";
    dump(names.substr(1+(int)name.size()), args...);
}
#else
    #define dbg(args...)
#endif

ll powmod(ll x, ll y)
{
    ll res = 1;
    x = x % MOD;
    while (y > 0)
    {
        if (y & 1)
  	      res = (res*x) % MOD;
        y = y>>1; // y = y/2
        x = (x*x) % MOD;
    }
    return res;
}
bool full(int mask){
	return (mask == 0 || mask == 3);
}

int get(int mask, int nmask){
	int cnt = __builtin_popcount(mask ^ nmask);
	if (cnt == 0) return 0;
	if (cnt == 2) return (full(mask) ? 1 : 2);
	return (full(mask) ? 1 : 0);
}
#define MAX 2005
ll dp[MAX][MAX][4];
ll calc(ll idx,ll comp,ll mask,ll n,ll k){
	if(idx==n){if(comp==k){ return 1;}else return 0;}
	if(dp[idx][comp][mask]!=-1)return dp[idx][comp][mask];
	ll val=0;
	rep(nmask,4){
		ll c=get(mask,nmask);
		dbg(idx,mask,nmask,c);
		val+=calc(idx+1,comp+get(mask,nmask),nmask,n,k);
	}
	return dp[idx][comp][mask]=val;
}

int main()
{
    #if !ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,k;cin>>n>>k;
    ll idx=1;
    ll ans=0;
    for(ll i=1;i<=n;i++){
    	for(int j=1;j<=2*n;j++){
    		rep(k,4)dp[i][j][k]=-1;
    	}
    }
	rep(mask,4){
		if(mask==0 || mask==3)ans+=calc(idx,1,mask,n,k);
		else ans+=calc(idx,2,mask,n,k);
		dbg(dp[1][1][3]);
		dbg(mask,ans);
	}
    cout<<ans<<endl;
}


#include <bits/stdc++.h>

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds;

#if !ONLINE_JUDGE
#define debug
#endif

using namespace std;

/*******  All Required define Pre-Processors and typedef Constants *******/
#define mem(a, b) memset(a, (b), sizeof(a))
#define repd(i,k) for(int i=k;i>=0;i--)
#define rep(i,k) for(int i=0;i<k;i++)
#define repn(i,k1,k2) for(ll i=k1;i<k2;i++)
#define sz(x) (ll)(x).size()
#define ff first
#define ss second

#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define INF (int)1e9
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define ee6 (ll)1000001
#define ee5 (ll)100001

#define trav(a, v) for(auto& a : v)

#define tt ll t;cin>>t; while(t--)
typedef long long int ll;

typedef pair<ll, ll> pr;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef vector<pr> vpr;
typedef vector<vpr>vvpr;
typedef vector<vi> vvi;

//*X.find_by_order(2) element at index=2
//X.order_of_key(1) how many elements strictly less than 1

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag,
    tree_order_statistics_node_update>;

#ifdef debug
#define dbg(...) { cerr<<"[ "; dump(#__VA_ARGS__, __VA_ARGS__);}
#undef endl
template <typename Arg1,typename Arg2>
ostream& operator << (ostream& out, const pair<Arg1,Arg2> &x) {
    return out<<"("<<x.ff<<","<<x.ss<<")";
}

template <typename Arg1>
ostream& operator << (ostream& out, const vector<Arg1> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}

template <typename Arg1>
ostream& operator << (ostream& out, const set<Arg1> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}

template <typename Arg1,typename Arg2>
ostream& operator << (ostream& out, const map<Arg1,Arg2> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}

template <typename Arg1,typename Arg2>
ostream& operator << (ostream& out, const unordered_map<Arg1,Arg2> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}

template <typename Arg1>
void dump(const string name, Arg1&& arg1){
    cerr << name << " : " << arg1 << " ] " << endl;
}

template <typename Arg1, typename... Args>
void dump(const string names, Arg1&& arg1, Args&&... args){
    const string name = names.substr(0,names.find(','));
    cerr<<name<<" : "<<arg1<<" | ";
    dump(names.substr(1+(int)name.size()), args...);
}
#else
    #define dbg(args...)
#endif

ll powmod(ll x, ll y)
{
    ll res = 1;
    x = x % MOD;
    while (y > 0)
    {
        if (y & 1)
  	      res = (res*x) % MOD;
        y = y>>1; // y = y/2
        x = (x*x) % MOD;
    }
    return res;
}
bool full(int mask){
	return (mask == 0 || mask == 3);
}

int get(int mask, int nmask){
	int cnt = __builtin_popcount(mask ^ nmask);
	if (cnt == 0) return 0;
	if (cnt == 2) return (full(mask) ? 1 : 2);
	return (full(mask) ? 1 : 0);
}
#define MAX 2005
#define MODS 998244353
ll dp[MAX][MAX][4];
ll calc(ll idx,ll comp,ll mask,ll n,ll k){
	if(idx==n){if(comp==k){ return 1;}else return 0;}
	if(dp[idx][comp][mask]!=-1)return dp[idx][comp][mask];
	ll val=0;
	rep(nmask,4){
		ll c=get(mask,nmask);
		dbg(idx,mask,nmask,c);
		val=(val%MODS+calc(idx+1,comp+get(mask,nmask),nmask,n,k)%MODS)%MODS;
	}
	return dp[idx][comp][mask]=val;
}

int main()
{
    #if !ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,k;cin>>n>>k;
    ll idx=1;
    ll ans=0;
    for(ll i=1;i<=n;i++){
    	for(int j=1;j<=2*n;j++){
    		rep(k,4)dp[i][j][k]=-1;
    	}
    }
	rep(mask,4){
		if(mask==0 || mask==3)ans=(ans%MODS+calc(idx,1,mask,n,k)%MODS)%MODS;
		else ans=(ans%MODS+calc(idx,2,mask,n,k)%MODS)%MODS;
		dbg(dp[1][1][3]);
		dbg(mask,ans);
	}
    cout<<ans<<endl;
}


#include <bits/stdc++.h>

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds;

#if !ONLINE_JUDGE
#define debug
#endif

using namespace std;

/*******  All Required define Pre-Processors and typedef Constants *******/
#define mem(a, b) memset(a, (b), sizeof(a))
#define repd(i,k) for(int i=k;i>=0;i--)
#define rep(i,k) for(int i=0;i<k;i++)
#define repn(i,k1,k2) for(ll i=k1;i<k2;i++)
#define sz(x) (ll)(x).size()
#define ff first
#define ss second

#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define INF (int)1e9
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define ee6 (ll)1000001
#define ee5 (ll)100001

#define trav(a, v) for(auto& a : v)

#define tt ll t;cin>>t; while(t--)
typedef long long int ll;

typedef pair<ll, ll> pr;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef vector<pr> vpr;
typedef vector<vpr>vvpr;
typedef vector<vi> vvi;

//*X.find_by_order(2) element at index=2
//X.order_of_key(1) how many elements strictly less than 1

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag,
    tree_order_statistics_node_update>;

#ifdef debug
#define dbg(...) { cerr<<"[ "; dump(#__VA_ARGS__, __VA_ARGS__);}
#undef endl
template <typename Arg1,typename Arg2>
ostream& operator << (ostream& out, const pair<Arg1,Arg2> &x) {
    return out<<"("<<x.ff<<","<<x.ss<<")";
}

template <typename Arg1>
ostream& operator << (ostream& out, const vector<Arg1> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}

template <typename Arg1>
ostream& operator << (ostream& out, const set<Arg1> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}

template <typename Arg1,typename Arg2>
ostream& operator << (ostream& out, const map<Arg1,Arg2> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}

template <typename Arg1,typename Arg2>
ostream& operator << (ostream& out, const unordered_map<Arg1,Arg2> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}

template <typename Arg1>
void dump(const string name, Arg1&& arg1){
    cerr << name << " : " << arg1 << " ] " << endl;
}

template <typename Arg1, typename... Args>
void dump(const string names, Arg1&& arg1, Args&&... args){
    const string name = names.substr(0,names.find(','));
    cerr<<name<<" : "<<arg1<<" | ";
    dump(names.substr(1+(int)name.size()), args...);
}
#else
    #define dbg(args...)
#endif

ll powmod(ll x, ll y)
{
    ll res = 1;
    x = x % MOD;
    while (y > 0)
    {
        if (y & 1)
  	      res = (res*x) % MOD;
        y = y>>1; // y = y/2
        x = (x*x) % MOD;
    }
    return res;
}
bool full(int mask){
	return (mask == 0 || mask == 3);
}

int get(int mask, int nmask){
	int cnt = __builtin_popcount(mask ^ nmask);
	if (cnt == 0) return 0;
	if (cnt == 2) return (full(mask) ? 1 : 2);
	return (full(mask) ? 1 : 0);
}
#define MAX 2005
ll dp[MAX][MAX][4];
ll calc(ll idx,ll comp,ll mask,ll n,ll k){
	if(idx==n){if(comp==k){ cout<<mask<<endl;return 1;}else return 0;}
	if(dp[idx][comp][mask]!=-1)return dp[idx][comp][mask];
	ll val=0;
	rep(nmask,4){
		ll c=get(mask,nmask);
		dbg(idx,mask,nmask,c);
		val+=calc(idx+1,comp+get(mask,nmask),nmask,n,k);
	}
	return dp[idx][comp][mask]=val;
}

int main()
{
    #if !ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,k;cin>>n>>k;
    ll idx=1;
    ll ans=0;
    for(ll i=1;i<=n;i++){
    	for(int j=1;j<=2*n;j++){
    		rep(k,4)dp[i][j][k]=-1;
    	}
    }
	rep(mask,4){
		if(mask==0 || mask==3)ans+=calc(idx,1,mask,n,k);
		else ans+=calc(idx,2,mask,n,k);
		dbg(dp[1][1][3]);
		dbg(mask,ans);
	}
    cout<<ans<<endl;
}


#include<bits/stdc++.h>
using namespace std;
#define ll          long long
#define pb          push_back
#define	endl		'\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(it,a)   for(auto it=(a).begin();it!=(a).end();it++)
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define inf        1000000007
#define rep(i,a,b)	for(ll int i=a;i<b;i++)
#define repr(i,a,b) for(ll int i=a;i>b;i--)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
long long int n,k;
long long int d5[1001][2001][4]={-1};
long long int dp(long long int i,string s,long long int k1)
{
	if (k1>k)return 0;
	long long int c=-1;
	if (s=="AA")
		c=0;
	if (s=="AB")
		c=1;
	if (s=="BA")
		c=2;
	if (s=="BB")
		c=3;
	if (d5[i][k1][c]!=-1)
	{
		return d5[i][k1][c];
	}
	if (i==n)
	{
	long long int count1=0;
	if (s=="AA")
	{
		if (k1==k)
			count1=count1+1;
		else if (k1==k-1)
			count1=count1+3;
		else
			count1=count1+0;
	}
	if (s=="AB")
	{
		if (k1==k)
			count1=count1+3;
		else if (k1==k-2)
			count1=count1+1;
		else
			count1=count1+0;
	}
	if (s=="BA")
	{
		if (k1==k)
			count1=count1+3;
		else if (k1==k-2)
			count1=count1+1;
		else
			count1=count1+0;
	}
	if (s=="BB")
	{
		if (k1==k)
			count1=count1+1;
		else if (k1==k-1)
			count1=count1+3;
		else
			count1=count1+0;
	}
	return d5[n][k1][c]=count1;
	}
	if (s=="AA")
	{
		long long int a1=dp(i+1,"AB",k1+1);
		long long int a2=dp(i+1,"AA",k1);
		long long int a3=dp(i+1,"BB",k1+1);
		long long int a4=dp(i+1,"BA",k1+1);
		return d5[i][k1][c]=(a1+a2+a3+a4)%998244353;
	}
	if (s=="AB")
	{
		ll a1=dp(i+1,"AB",k1);
		ll a2=dp(i+1,"AA",k1);
		ll a3=dp(i+1,"BB",k1);
		ll a4=dp(i+1,"BA",k1+2);
		return d5[i][k1][c]=(a1+a2+a3+a4)%998244353;
	}
	if (s=="BA")
	{
		ll a1=dp(i+1,"AB",k1+2);
		ll a2=dp(i+1,"AA",k1);
		ll a3=dp(i+1,"BB",k1);
		ll a4=dp(i+1,"BA",k1);
		return d5[i][k1][c]=(a1+a2+a3+a4)%998244353;
	}
	if (s=="BB")
	{
		ll a1=dp(i+1,"AB",k1+1);
		ll a2=dp(i+1,"AA",k1+1);
		ll a3=dp(i+1,"BB",k1);
		ll a4=dp(i+1,"BA",k1+1);
		return d5[i][k1][c]=(a1+a2+a3+a4)%998244353;
	}
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin >> n >> k;
	rep(i,1,n+1)
	{
		rep(j,1,2*n+1)
		{
			rep(z,0,4)
			{
				d5[i][j][z]=-1;
			}
		}
	}
	if (n==1)
	{
		cout << 2 << endl;
		exit(0);
	}
	ll d1=dp(2,"AB",2);
	ll d2=dp(2,"BA",2);
	ll d3=dp(2,"AA",1);
	ll d4=dp(2,"BB",1);
	cout << (d1+d2+d3+d4)%998244353 << endl;
}


#include<bits/stdc++.h>
using namespace std;
#define ll          long long
#define pb          push_back
#define	endl		'\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(it,a)   for(auto it=(a).begin();it!=(a).end();it++)
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define inf        1000000007
#define rep(i,a,b)	for(ll int i=a;i<b;i++)
#define repr(i,a,b) for(ll int i=a;i>b;i--)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
long long int n,k;
long long int d5[1001][2001][4]={-1};
long long int dp(long long int i,string s,long long int k1)
{
	if (k1>k)return 0;
	long long int c=-1;
	if (s=="AA")
		c=0;
	if (s=="AB")
		c=1;
	if (s=="BA")
		c=2;
	if (s=="BB")
		c=3;
	if (d5[i][k1][c]!=-1)
	{
		return d5[i][k1][c];
	}
	if (i==n)
	{
	long long int count1=0;
	if (s=="AA")
	{
		if (k1==k)
			count1=count1+1;
		else if (k1==k-1)
			count1=count1+3;
		else
			count1=count1+0;
	}
	if (s=="AB")
	{
		if (k1==k)
			count1=count1+3;
		else if (k1==k-2)
			count1=count1+1;
		else
			count1=count1+0;
	}
	if (s=="BA")
	{
		if (k1==k)
			count1=count1+3;
		else if (k1==k-2)
			count1=count1+1;
		else
			count1=count1+0;
	}
	if (s=="BB")
	{
		if (k1==k)
			count1=count1+1;
		else if (k1==k-1)
			count1=count1+3;
		else
			count1=count1+0;
	}
	return d5[n][k1][c]=count1;
	}
	if (s=="AA")
	{
		long long int a1=dp(i+1,"AB",k1+1);
		long long int a2=dp(i+1,"AA",k1);
		long long int a3=dp(i+1,"BB",k1+1);
		long long int a4=dp(i+1,"BA",k1+1);
		return d5[i][k1][c]=(a1+a2+a3+a4)%998244353;
	}
	if (s=="AB")
	{
		ll a1=dp(i+1,"AB",k1);
		ll a2=dp(i+1,"AA",k1);
		ll a3=dp(i+1,"BB",k1);
		ll a4=dp(i+1,"BA",k1+2);
		return d5[i][k1][c]=(a1+a2+a3+a4)%998244353;
	}
	if (s=="BA")
	{
		ll a1=dp(i+1,"AB",k1+2);
		ll a2=dp(i+1,"AA",k1);
		ll a3=dp(i+1,"BB",k1);
		ll a4=dp(i+1,"BA",k1);
		return d5[i][k1][c]=(a1+a2+a3+a4)%998244353;
	}
	if (s=="BB")
	{
		ll a1=dp(i+1,"AB",k1+1);
		ll a2=dp(i+1,"AA",k1+1);
		ll a3=dp(i+1,"BB",k1);
		ll a4=dp(i+1,"BA",k1+1);
		return d5[i][k1][c]=(a1+a2+a3+a4)%998244353;
	}
}
int main()
{
	cin >> n >> k;
	rep(i,1,n+1)
	{
		rep(j,1,2*n+1)
		{
			rep(z,0,4)
			{
				d5[i][j][z]=-1;
			}
		}
	}
	if (n==1)
	{
		cout << 2 << endl;
		exit(0);
	}
	ll d1=dp(2,"AB",2);
	ll d2=dp(2,"BA",2);
	ll d3=dp(2,"AA",1);
	ll d4=dp(2,"BB",1);
	cout << (d1+d2+d3+d4)%998244353 << endl;
}


/*fuck off*/
#include<bits/stdc++.h>
using namespace std;
#define ll          long long
#define pb          push_back
#define	endl		'\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(it,a)   for(auto it=(a).begin();it!=(a).end();it++)
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define inf        1000000007
#define rep(i,a,b)	for(ll int i=a;i<b;i++)
#define repr(i,a,b) for(ll int i=a;i>b;i--)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
long long int n,k;
long long int d5[1001][2001][4]={-1};
long long int dp(long long int i,string s,long long int k1)
{
	if (k1>k)return 0;
	long long int c=-1;
	if (s=="AA")
		c=0;
	if (s=="AB")
		c=1;
	if (s=="BA")
		c=2;
	if (s=="BB")
		c=3;
	if (d5[i][k1][c]!=-1)
	{
		return d5[i][k1][c];
	}
	if (i==n)
	{
	long long int count1=0;
	if (s=="AA")
	{
		if (k1==k)
			count1=count1+1;
		else if (k1==k-1)
			count1=count1+3;
		else
			count1=count1+0;
	}
	if (s=="AB")
	{
		if (k1==k)
			count1=count1+3;
		else if (k1==k-2)
			count1=count1+1;
		else
			count1=count1+0;
	}
	if (s=="BA")
	{
		if (k1==k)
			count1=count1+3;
		else if (k1==k-2)
			count1=count1+1;
		else
			count1=count1+0;
	}
	if (s=="BB")
	{
		if (k1==k)
			count1=count1+1;
		else if (k1==k-1)
			count1=count1+3;
		else
			count1=count1+0;
	}
	return d5[n][k1][c]=count1;
	}
	if (s=="AA")
	{
		long long int a1=dp(i+1,"AB",k1+1);
		long long int a2=dp(i+1,"AA",k1);
		long long int a3=dp(i+1,"BB",k1+1);
		long long int a4=dp(i+1,"BA",k1+1);
		return d5[i][k1][c]=(a1+a2+a3+a4)%998244353;
	}
	if (s=="AB")
	{
		ll a1=dp(i+1,"AB",k1);
		ll a2=dp(i+1,"AA",k1);
		ll a3=dp(i+1,"BB",k1);
		ll a4=dp(i+1,"BA",k1+2);
		return d5[i][k1][c]=(a1+a2+a3+a4)%998244353;
	}
	if (s=="BA")
	{
		ll a1=dp(i+1,"AB",k1+2);
		ll a2=dp(i+1,"AA",k1);
		ll a3=dp(i+1,"BB",k1);
		ll a4=dp(i+1,"BA",k1);
		return d5[i][k1][c]=(a1+a2+a3+a4)%998244353;
	}
	if (s=="BB")
	{
		ll a1=dp(i+1,"AB",k1+1);
		ll a2=dp(i+1,"AA",k1+1);
		ll a3=dp(i+1,"BB",k1);
		ll a4=dp(i+1,"BA",k1+1);
		return d5[i][k1][c]=(a1+a2+a3+a4)%998244353;
	}
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin >> n >> k;
	rep(i,1,n+1)
	{
		rep(j,1,2*n+1)
		{
			rep(z,0,4)
			{
				d5[i][j][z]=-1;
			}
		}
	}
	if (n==1)
	{
		cout << 2 << endl;
		exit(0);
	}
	ll d1=dp(2,"AB",2);
	ll d2=dp(2,"BA",2);
	ll d3=dp(2,"AA",1);
	ll d4=dp(2,"BB",1);
	cout << (d1+d2+d3+d4)%998244353 << endl;
}


#include<bits/stdc++.h>
using namespace std;
#define int          long long
#define pb          push_back
#define	endl		'\n'
#define pii         pair<int int,int int>
#define vi          vector<int int>
#define aint(it,a)   for(auto it=(a).begin();it!=(a).end();it++)
#define F           first
#define S           second
#define sz(x)       (int int)x.size()
#define inf        1000000007
#define rep(i,a,b)	for(int i=a;i<b;i++)
#define repr(i,a,b) for(int i=a;i>b;i--)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
int n,k;
int d5[1001][2001][4];
int dp(int i,string s,int k1)
{
	if (k1>k)return 0;
	int c=-1;
	if (s=="AA")
		c=0;
	if (s=="AB")
		c=1;
	if (s=="BA")
		c=2;
	if (s=="BB")
		c=3;
	if (d5[i][k1][c]!=-1)
	{
		return d5[i][k1][c];
	}
	if (i==n)
	{
	int count1=0;
	if (s=="AA")
	{
		if (k1==k)
			count1=count1+1;
		else if (k1==k-1)
			count1=count1+3;
		else
			count1=count1+0;
	}
	if (s=="AB")
	{
		if (k1==k)
			count1=count1+3;
		else if (k1==k-2)
			count1=count1+1;
		else
			count1=count1+0;
	}
	if (s=="BA")
	{
		if (k1==k)
			count1=count1+3;
		else if (k1==k-2)
			count1=count1+1;
		else
			count1=count1+0;
	}
	if (s=="BB")
	{
		if (k1==k)
			count1=count1+1;
		else if (k1==k-1)
			count1=count1+3;
		else
			count1=count1+0;
	}
	return d5[n][k1][c]=count1;
	}
	if (s=="AA")
	{
		int a1=dp(i+1,"AB",k1+1);
		int a2=dp(i+1,"AA",k1);
		int a3=dp(i+1,"BB",k1+1);
		int a4=dp(i+1,"BA",k1+1);
		return d5[i][k1][c]=(a1+a2+a3+a4)%998244353;
	}
	if (s=="AB")
	{
		int a1=dp(i+1,"AB",k1);
		int a2=dp(i+1,"AA",k1);
		int a3=dp(i+1,"BB",k1);
		int a4=dp(i+1,"BA",k1+2);
		return d5[i][k1][c]=(a1+a2+a3+a4)%998244353;
	}
	if (s=="BA")
	{
		int a1=dp(i+1,"AB",k1+2);
		int a2=dp(i+1,"AA",k1);
		int a3=dp(i+1,"BB",k1);
		int a4=dp(i+1,"BA",k1);
		return d5[i][k1][c]=(a1+a2+a3+a4)%998244353;
	}
	if (s=="BB")
	{
		int a1=dp(i+1,"AB",k1+1);
		int a2=dp(i+1,"AA",k1+1);
		int a3=dp(i+1,"BB",k1);
		int a4=dp(i+1,"BA",k1+1);
		return d5[i][k1][c]=(a1+a2+a3+a4)%998244353;
	}
}
main()
{
	cin >> n >> k;
	rep(i,1,n+1)
	{
		rep(j,1,2*n+1)
		{
			rep(z,0,4)
			{
				d5[i][j][z]=-1;
			}
		}
	}
	if (n==1)
	{
		cout << 2 << endl;
		exit(0);
	}
	int d1=dp(2,"AB",2);
	int d2=dp(2,"BA",2);
	int d3=dp(2,"AA",1);
	int d4=dp(2,"BB",1);
	cout << (d1+d2+d3+d4)%998244353 << endl;
}


#include <bits/stdc++.h>
using namespace std;

typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> pll;
#define all(v) (v).begin(),(v).end()
#define endl "\n"
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

ll const inf = 1e18;
ll const maxn = 1e5+5;
ll const mod = 1e9+7;

// code begins here

ll n,m,s, flag=-1;
map<pll, vector<pll>> v;
map<pll, ll> vis;
map<pll, pll> parent;
vector<ll> order;

void dfs(pll i){
    vis[i] = 1;
    for(auto u: v[i]){
        if(vis[u])
            continue;
        parent[u] = i;
        dfs(u);
    }
}

void dfs1(pll i){
    vis[i] = 1;
    for(auto u: v[i]){
        if(vis[u])
            continue;
        dfs1(u);
    }
    order.push_back(i.first);
}

bool check_cycle(){
    vis.clear();

    dfs1({s,1});

    reverse(order.begin(), order.end());
    vector<ll> pos(n+1);
    ll sz = order.size();
    for(ll i=0;i<sz;i++)
        pos[order[i]] = i;

    for(ll i=1;i<=n;i++){
        for(auto u: v[{i, 0}]){
            if(pos[u.first]<pos[i])
                return true;
        }
    }
    return false;
}

bool can_win(){

    dfs({s,1});

    for(ll i=1;i<=n;i++){
        ll sz = v[{i,0}].size();
        if(vis[{i,0}] && !sz)
            flag = i;
    }

    if(flag==-1)
        return false;

    cout<<"Win"<<endl;
    vector<ll> ans;
    pll i = {flag,0};
    while(i.first){
        ans.push_back(i.first);
        i = parent[i];
    }

    reverse(all(ans));
    for(auto u: ans)
        cout<<u<<" ";
    return true;
}

int main(){
    fast;

    cin>>n>>m;

    for(ll i=1;i<=n;i++){
        ll c, x;
        cin>>c;
        for(ll j=1;j<=c;j++){
            cin>>x;
            v[{i,0}].push_back({x,1});
            v[{i,1}].push_back({x,0});
        }
    }

    cin>>s;

    if(can_win())
        return 0;

    cout<< (check_cycle() ? "Draw" : "Lose") <<endl;

    return 0;
}


#include <bits/stdc++.h>
using namespace std;

typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> pll;
#define all(v) (v).begin(),(v).end()
#define endl "\n"
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

ll const inf = 1e18;
ll const maxn = 1e6+5;
ll const mod = 1e9+7;

// code begins here

ll n,m,s, flag = -1;
vector<ll> v[maxn], vis(maxn), parent(maxn);
vector<ll> order;
ll arr[maxn][2];

void dfs(ll i, ll lev = 0){
    vis[i] = 1;
    for(auto u: v[i]){
        if(vis[u]){
            if(arr[u][0]){
                if(lev%2==0){
                    flag = arr[u][0];
                    parent[u] = i;
                    return;
                }
                arr[i][1] = arr[u][0];
            }
            if(arr[u][1]){
                if(lev&1){
                    flag = arr[u][1];
                    parent[u] = i;
                    return;
                }
                arr[i][0] = arr[u][1];
            }
            continue;
        }

        ll sz = v[u].size();
        if(sz==0)
            arr[i][1] = u;

        parent[u] = i;
        dfs(u, lev+1);
    }
}

void dfs1(ll i){
    vis[i] = 1;
    for(auto u: v[i]){
        if(vis[u])
            continue;
        dfs1(u);
    }
    order.push_back(i);
}

bool check_cycle(){
    for(ll i=1;i<=n;i++)
        vis[i] = 0;
    dfs1(s);

    reverse(order.begin(), order.end());
    vector<ll> pos(n+1);
    ll sz = order.size();
    for(ll i=0;i<sz;i++)
        pos[order[i]] = i;

    for(ll i=1;i<=n;i++){
        for(auto u: v[i]){
            if(pos[u]<pos[i])
                return true;
        }
    }
    return false;
}

bool can_win(){
    for(ll i=1;i<=n;i++){
        arr[i][0] = 0;
        arr[i][1] = 0;
    }

    dfs(s);

    if(flag==-1)
        return false;

    cout<<"Win"<<endl;
    vector<ll> ans;
    ll i = flag;
    while(i!=0){
        ans.push_back(i);
        i = parent[i];
    }

    reverse(all(ans));
    for(auto u: ans)
        cout<<u<<" ";
    return true;
}

int main(){
    fast;

    cin>>n>>m;

    for(ll i=1;i<=n;i++){
        ll c, x;
        cin>>c;
        for(ll j=1;j<=c;j++){
            cin>>x;
            v[i].push_back(x);
        }
    }

    cin>>s;

    if(can_win())
        return 0;

    cout<< (check_cycle() ? "Draw" : "Lose") <<endl;

    return 0;
}


#include <bits/stdc++.h>
using namespace std;

typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> pll;
#define all(v) (v).begin(),(v).end()
#define endl "\n"
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

ll const inf = 1e18;
ll const maxn = 1e5+5;
ll const mod = 1e9+7;

// code begins here

ll n,m,s, flag = -1;
map<ll, vector<ll>> v;
map<ll, ll> vis, parent;
map<ll, pll> arr;
vector<ll> order;

void dfs(ll i, ll lev = 0){
    vis[i] = 1;
    for(auto u: v[i]){
        if(vis[u])
            continue;

        ll sz = v[u].size();
        if(sz==0)
            arr[i].second = u;

        parent[u] = i;
        dfs(u, lev+1);
    }

    for(auto u: v[i]){
        if(arr[u].first){
            if(lev%2==0){
                flag = arr[u].first;
                parent[u] = i;
                return;
            }
            arr[i].second = arr[u].first;
        }
        if(arr[u].second){
            if(lev&1){
                flag = arr[u].second;
                parent[u] = i;
                return;
            }
            arr[i].first = arr[u].second;
        }
    }
}

void dfs1(ll i){
    vis[i] = 1;
    for(auto u: v[i]){
        if(vis[u])
            continue;
        dfs1(u);
    }
    order.push_back(i);
}

bool check_cycle(){
    vis.clear();
    dfs1(s);

    reverse(all(order));
    vector<ll> pos(n+1);
    ll sz = order.size();
    for(ll i=0;i<sz;i++)
        pos[order[i]] = i;

    for(ll i=1;i<=n;i++){
        for(auto u: v[i]){
            if(pos[u]<pos[i])
                return true;
        }
    }
    return false;
}

bool can_win(){
    dfs(s);

    if(flag==-1)
        return false;

    cout<<"Win"<<endl;
    vector<ll> ans;
    ll i = flag;
    while(i!=0){
        ans.push_back(i);
        i = parent[i];
    }

    reverse(all(ans));
    for(auto u: ans)
        cout<<u<<" ";
    return true;
}

int main(){
    fast;

    cin>>n>>m;

    for(ll i=1;i<=n;i++){
        ll c, x;
        cin>>c;
        for(ll j=1;j<=c;j++){
            cin>>x;
            v[i].push_back(x);
        }
    }

    cin>>s;

    if(can_win())
        return 0;

    cout<< (check_cycle() ? "Draw" : "Lose") <<endl;

    return 0;
}


#include <bits/stdc++.h>
using namespace std;

typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> pll;
#define all(v) (v).begin(),(v).end()
#define endl "\n"
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

ll const inf = 1e18;
ll const maxn = 1e6+5;
ll const mod = 1e9+7;

// code begins here

ll n,m,s, flag = -1;
vector<ll> v[maxn], vis(maxn), parent(maxn);
vector<ll> order;
ll arr[maxn][2];

void dfs(ll i, ll lev = 0){
    vis[i] = 1;
    for(auto u: v[i]){
        if(vis[u]){
            if(arr[u][0]){
                if(lev%2==0){
                    flag = arr[u][0];
                    parent[u] = i;
                    return;
                }
                arr[i][1] = arr[u][0];
            }
            if(arr[u][1]){
                if(lev&1){
                    flag = arr[u][1];
                    parent[u] = i;
                    return;
                }
                arr[i][0] = arr[u][1];
            }
            continue;
        }

        ll sz = v[u].size();
        if(sz==0)
            arr[i][1] = u;

        parent[u] = i;
        dfs(u, lev+1);

        if(arr[u][0]){
            if(lev%2==0){
                flag = arr[u][0];
                parent[u] = i;
                return;
            }
            arr[i][1] = arr[u][0];
        }
        if(arr[u][1]){
            if(lev&1){
                flag = arr[u][1];
                parent[u] = i;
                return;
            }
            arr[i][0] = arr[u][1];
        }
    }
}

void dfs1(ll i){
    vis[i] = 1;
    for(auto u: v[i]){
        if(vis[u])
            continue;
        dfs1(u);
    }
    order.push_back(i);
}

bool check_cycle(){
    for(ll i=1;i<=n;i++)
        vis[i] = 0;
    dfs1(s);

    reverse(order.begin(), order.end());
    vector<ll> pos(n+1);
    ll sz = order.size();
    for(ll i=0;i<sz;i++)
        pos[order[i]] = i;

    for(ll i=1;i<=n;i++){
        for(auto u: v[i]){
            if(pos[u]<pos[i])
                return true;
        }
    }
    return false;
}

bool can_win(){
    for(ll i=1;i<=n;i++){
        arr[i][0] = 0;
        arr[i][1] = 0;
    }

    dfs(s);

    if(flag==-1)
        return false;

    cout<<"Win"<<endl;
    vector<ll> ans;
    ll i = flag;
    while(i!=0){
        ans.push_back(i);
        i = parent[i];
    }

    reverse(all(ans));
    for(auto u: ans)
        cout<<u<<" ";
    return true;
}

int main(){
    fast;

    cin>>n>>m;

    for(ll i=1;i<=n;i++){
        ll c, x;
        cin>>c;
        for(ll j=1;j<=c;j++){
            cin>>x;
            v[i].push_back(x);
        }
    }

    cin>>s;

    if(can_win())
        return 0;

    cout<< (check_cycle() ? "Draw" : "Lose") <<endl;

    return 0;
}


#include <bits/stdc++.h>
using namespace std;

typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> pll;
#define all(v) (v).begin(),(v).end()
#define endl "\n"
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

ll const inf = 1e18;
ll const maxn = 1e5+5;
ll const mod = 1e9+7;

// code begins here

ll n,m,s, flag = -1;
vector<ll> v[maxn], vis(maxn), parent(maxn);
vector<ll> order;
ll arr[maxn][2];

void dfs(ll i, ll lev = 0){
    vis[i] = 1;
    for(auto u: v[i]){
        if(vis[u]){
            if(arr[u][0]){
                if(lev%2==0){
                    flag = arr[u][0];
                    parent[u] = i;
                    return;
                }
                arr[i][1] = arr[u][0];
            }
            if(arr[u][1]){
                if(lev&1){
                    flag = arr[u][1];
                    parent[u] = i;
                    return;
                }
                arr[i][0] = arr[u][1];
            }
            continue;
        }

        ll sz = v[u].size();
        if(sz==0)
            arr[i][1] = u;

        parent[u] = i;
        dfs(u, lev+1);

        if(arr[u][0]){
            if(lev%2==0){
                flag = arr[u][0];
                parent[u] = i;
                return;
            }
            arr[i][1] = arr[u][0];
        }
        if(arr[u][1]){
            if(lev&1){
                flag = arr[u][1];
                parent[u] = i;
                return;
            }
            arr[i][0] = arr[u][1];
        }
    }
}

void dfs1(ll i){
    vis[i] = 1;
    for(auto u: v[i]){
        if(vis[u])
            continue;
        dfs1(u);
    }
    order.push_back(i);
}

bool check_cycle(){
    for(ll i=1;i<=n;i++)
        vis[i] = 0;
    dfs1(s);

    reverse(order.begin(), order.end());
    vector<ll> pos(n+1);
    ll sz = order.size();
    for(ll i=0;i<sz;i++)
        pos[order[i]] = i;

    for(ll i=1;i<=n;i++){
        for(auto u: v[i]){
            if(pos[u]<pos[i])
                return true;
        }
    }
    return false;
}

bool can_win(){
    for(ll i=1;i<=n;i++){
        arr[i][0] = 0;
        arr[i][1] = 0;
    }

    dfs(s);

    if(flag==-1)
        return false;

    cout<<"Win"<<endl;
    vector<ll> ans;
    ll i = flag;
    while(i!=0){
        ans.push_back(i);
        i = parent[i];
    }

    reverse(all(ans));
    for(auto u: ans)
        cout<<u<<" ";
    return true;
}

int main(){
    fast;

    cin>>n>>m;

    for(ll i=1;i<=n;i++){
        ll c, x;
        cin>>c;
        for(ll j=1;j<=c;j++){
            cin>>x;
            v[i].push_back(x);
        }
    }

    cin>>s;

    if(can_win())
        return 0;

    cout<< (check_cycle() ? "Draw" : "Lose") <<endl;

    return 0;
}


#include<bits/stdc++.h>

#define ll long long
using namespace std;
const int N = 1e5 + 5, M = 3e6 + 5;
vector<int> g[N];
int vis[N];
int z[N]; // 1 lose
bool d;

void dfs(int node) {
    if (vis[node] == 2) return void(d = 1);
    vis[node]++;
    for (auto child : g[node]) {
        dfs(child);
        z[node] |= z[child];
    }
    if (g[node].empty()) z[node] = 1;
    else {
        if (z[node] == 1) z[node] = 2;
        else if (z[node] == 2) z[node] = 1;
    }
}

void build(int node, int p) {
    vis[node] = 1;
    cout << node << ' ';
    for (auto child : g[node]) {
        if ((z[child] & p) && !vis[child]) {
            build(child, (p == 1) ? 2 : 1);
            return;
        }
    }
}

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int n, m;
    cin >> n >> m;
    for (int i = 1; i <= n; i++) {
        cin >> m;
        for (int j = 1; j <= m; j++) {
            int x;
            cin >> x;
            g[i].push_back(x);
        }
    }
    int root;
    cin >> root;
    dfs(root);
    memset(vis, 0, sizeof vis);
    if (z[root] & 2) {
        cout << "Win\n";
        build(root, 1);
    } else if (d) cout << "Draw";
    else cout << "Lose";
    return 0;
}


#include<bits/stdc++.h>

#define ll long long
using namespace std;
const int N = 1e5 + 5, M = 3e6 + 5;
vector<int> g[N];
int vis[N][2];
int z[N]; // 1 lose
bool d, w;
vector<int> v;
bool viss[N], instk[N];

void ch(int node) {
    if (instk[node]) return void(d = 1);
    if (viss[node]) return;
    viss[node] = instk[node] = 1;
    for (auto child : g[node]) ch(child);
    instk[node] = 0;
}

void dfs(int node, int p) {
    if (vis[node][p]) return;
    vis[node][p] = 1;
    for (auto child : g[node]) {
        dfs(child, !p);
        if (w) return void(v.push_back(child));
    }
    if (g[node].empty() && p == 1) w = 1;
}

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int n, m;
    cin >> n >> m;
    for (int i = 1; i <= n; i++) {
        cin >> m;
        for (int j = 1; j <= m; j++) {
            int x;
            cin >> x;
            g[i].push_back(x);
        }
    }
    int root;
    cin >> root;
    ch(root);
    dfs(root, 0);
    if (w) {
        cout << "Win\n";
        v.push_back(root);
        reverse(v.begin(), v.end());
        for (auto it : v) cout << it << ' ';
    } else if (d) {
        cout << "Draw";
    } else cout << "Lose";
    return 0;
}


#include<bits/stdc++.h>

#define ll long long
using namespace std;
const int N = 1e5 + 5, M = 3e6 + 5;
vector < int > g[N];
bool vis[N];
int z[N]; // 1 lose
void dfs(int node) {
    if (vis[node]) return;
    vis[node] = 1;
    for(auto child : g[node]) {
        dfs(child);
        z[node] |= z[child];
    }
    if (g[node].empty()) z[node] = 1;
    else {
        if (z[node] == 1) z[node] = 2;
        else if (z[node] == 2) z[node] = 1;
    }
}
void build(int node, int p) {
    cout << node <<' ';
    for(auto child : g[node]) {
        if (z[child] & p){
            build(child, (p == 1) ? 2 : 1);
            return;
        }
    }
}
int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int n, m;
    cin >> n >> m;
    bool bo = 0;
    for(int i = 1 ; i <= n ; i++) {
        cin >> m;
        bo |= (m == 0);
        for(int j = 1 ; j <= m ; j++) {
            int x; cin >> x;
            g[i].push_back(x);
        }
    }
    if (!bo) return cout << "Draw", 0;
    int root; cin >> root;
    dfs(root);
    if (z[root] == 1) cout << "Lose";
    else {
        cout << "Win\n";
        build(root, 1);
    }
    return 0;
}


#include<bits/stdc++.h>

#define ll long long
using namespace std;
const int N = 1e5 + 5, M = 3e6 + 5;
vector < int > g[N];
bool vis[N];
int z[N]; // 1 lose
void dfs(int node) {
    if (vis[node]) return;
    vis[node] = 1;
    for(auto child : g[node]) {
        dfs(child);
        z[node] |= z[child];
    }
    if (g[node].empty()) z[node] = 1;
    else {
        if (z[node] == 1) z[node] = 2;
        else if (z[node] == 2) z[node] = 1;
    }
}
void build(int node, int p) {
    cout << node <<' ';
    for(auto child : g[node]) {
        if (z[child] & p){
            build(child, (p == 1) ? 2 : 1);
            return;
        }
    }
}
int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int n, m;
    cin >> n >> m;
    for(int i = 1 ; i <= n ; i++) {
        cin >> m;
        for(int j = 1 ; j <= m ; j++) {
            int x; cin >> x;
            g[i].push_back(x);
        }
    }
    int root; cin >> root;
    dfs(root);
    if (z[root] == 0) cout << "Draw";
    else if (z[root] == 1) cout << "Lose";
    else {
        cout << "Win\n";
        build(root, 1);
    }
    return 0;
}


#include<bits/stdc++.h>

#define ll long long
using namespace std;
const int N = 1e5 + 5, M = 3e6 + 5;
vector < int > g[N];
bool vis[N];
int z[N]; // 1 lose
void dfs(int node) {
    if (vis[node]) return;
    vis[node] = 1;
    for(auto child : g[node]) {
        dfs(child);
        z[node] |= z[child];
    }
    if (g[node].empty()) z[node] = 1;
    else {
        if (z[node] == 1) z[node] = 2;
        else if (z[node] == 2) z[node] = 1;
    }
}
void build(int node, int p) {
    if (vis[node]) return;
    vis[node] = 1;
    cout << node <<' ';
    for(auto child : g[node]) {
        if (z[child] & p){
            build(child, (p == 1) ? 2 : 1);
            return;
        }
    }
}
int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int n, m;
    cin >> n >> m;
    for(int i = 1 ; i <= n ; i++) {
        cin >> m;
        for(int j = 1 ; j <= m ; j++) {
            int x; cin >> x;
            g[i].push_back(x);
        }
    }
    int root; cin >> root;
    dfs(root);
    memset(vis, 0, sizeof vis);
    if (z[root] == 0) cout << "Draw";
    else if (z[root] == 1) cout << "Lose";
    else {
        cout << "Win\n";
        build(root, 1);
    }
    return 0;
}


#include<bits/stdc++.h>

#define ll long long
using namespace std;
const int N = 1e5 + 5, M = 3e6 + 5;
vector < int > g[N];
bool vis[N];
int z[N]; // 1 lose
void dfs(int node) {
    if (vis[node]) return;
    vis[node] = 1;
    for(auto child : g[node]) {
        dfs(child);
        z[node] |= z[child];
    }
    if (g[node].empty()) z[node] = 1;
    else {
        if (z[node] == 1) z[node] = 2;
        else if (z[node] == 2) z[node] = 1;
    }
}
void build(int node, int p) {
    vis[node] = 1;
    cout << node <<' ';
    for(auto child : g[node]) {
        if ((z[child] & p) && !vis[child]){
            build(child, (p == 1) ? 2 : 1);
            return;
        }
    }
}
int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int n, m;
    cin >> n >> m;
    for(int i = 1 ; i <= n ; i++) {
        cin >> m;
        for(int j = 1 ; j <= m ; j++) {
            int x; cin >> x;
            g[i].push_back(x);
        }
    }
    int root; cin >> root;
    dfs(root);
    memset(vis, 0, sizeof vis);
    if (z[root] == 0) cout << "Draw";
    else if (z[root] == 1) cout << "Lose";
    else {
        cout << "Win\n";
        build(root, 1);
    }
    return 0;
}


#include<bits/stdc++.h>

#define ll long long
using namespace std;
const int N = 1e5 + 5, M = 3e6 + 5;
vector<int> g[N];
int vis[N];
int z[N]; // 1 lose
bool d;

void dfs(int node) {
    if (vis[node] == 2) return void(d = 1);
    vis[node]++;
    for (auto child : g[node]) {
        dfs(child);
        z[node] |= z[child];
    }
    if (g[node].empty()) z[node] = 1;
    else {
        if (z[node] == 1) z[node] = 2;
        else if (z[node] == 2) z[node] = 1;
    }
}

void build(int node, int p) {
    vis[node]++;
    cout << node << ' ';
    for (auto child : g[node]) {
        if ((z[child] & p) && vis[child] != 2) {
            build(child, (p == 1) ? 2 : 1);
            return;
        }
    }
}

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int n, m;
    cin >> n >> m;
    for (int i = 1; i <= n; i++) {
        cin >> m;
        for (int j = 1; j <= m; j++) {
            int x;
            cin >> x;
            g[i].push_back(x);
        }
    }
    int root;
    cin >> root;
    dfs(root);
    memset(vis, 0, sizeof vis);
    if (z[root] & 2) {
        cout << "Win\n";
        build(root, 1);
    } else if (d) cout << "Draw";
    else cout << "Lose";
    return 0;
}


#include<bits/stdc++.h>

#define ll long long
using namespace std;
const int N = 1e5 + 5, M = 3e6 + 5;
vector<int> g[N];
int vis[N][2];
int z[N]; // 1 lose
bool d, w;
vector<int> v;

void dfs(int node, int p) {
    if (vis[node][p] || vis[node][!p]) d = 1;
    if (vis[node][p]) return;
    vis[node][p] = 1;
    for (auto child : g[node]) {
        dfs(child, !p);
        if (w) return void(v.push_back(child));
    }
    if (g[node].empty() && p == 1) w = 1;
}

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int n, m;
    cin >> n >> m;
    for (int i = 1; i <= n; i++) {
        cin >> m;
        for (int j = 1; j <= m; j++) {
            int x;
            cin >> x;
            g[i].push_back(x);
        }
    }
    int root;
    cin >> root;
    dfs(root, 0);
    if (w) {
        cout << "Win\n";
        v.push_back(root);
        reverse(v.begin(), v.end());
        for (auto it : v) cout << it << ' ';
    } else if (d) {
        cout << "Draw";
    } else cout << "Lose";
    return 0;
}


#include<bits/stdc++.h>

#define ll long long
using namespace std;
const int N = 1e5 + 5, M = 3e6 + 5;
vector<int> g[N];
int vis[N][2];
int z[N]; // 1 lose
bool d, w;
vector<int> v;

void dfs(int node, int p) {
    if (vis[node][p]) d = 1;
    if (vis[node][p]) return;
    vis[node][p] = 1;
    for (auto child : g[node]) {
        dfs(child, !p);
        if (w) return void(v.push_back(child));
    }
    if (g[node].empty() && p == 1) w = 1;
}

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int n, m;
    cin >> n >> m;
    for (int i = 1; i <= n; i++) {
        cin >> m;
        for (int j = 1; j <= m; j++) {
            int x;
            cin >> x;
            g[i].push_back(x);
        }
    }
    int root;
    cin >> root;
    dfs(root, 0);
    if (w) {
        cout << "Win\n";
        v.push_back(root);
        reverse(v.begin(), v.end());
        for (auto it : v) cout << it << ' ';
    } else if (d) {
        cout << "Draw";
    } else cout << "Lose";
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAX = 2e9;
typedef pair<int, int> pi;
int n, m;
vector<vector<int>>g;
bool vis[100003][2];
bool iswin, iscycle;
vector<int>ans;
int isin[100003];
void dfs(int u, bool c) {
    if (iswin)return;
    vis[u][c] = 1;
    ans.push_back(u);
    isin[u]++;
    if (g[u].size() == 0) { // if outdegree is 0
        if (c == 0) {
            iswin = 1;
            cout << "Win" << "\n";
            for (int i : ans)cout << i << " ";
            return;
        }
    }
    for (int v : g[u]) {
        int nc = 1 - c;
        if (isin[v])iscycle = 1;
        if (vis[v][nc]==0)dfs(v, nc);
    }
    if (iswin)return;
    isin[u]--;
    ans.pop_back();
}
int main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> n >> m;
    g.resize(n + 1);
    for (int i = 1; i <= n; i++) {
        int c;
        cin >> c;
        set<int> s;
        for (int j = 0; j < c; j++) {
            int v;
            cin >> v;
            s.insert(v);
        }
        for (int j : s)g[i].push_back(j);
    }
    int s;
    cin >> s;
    dfs(s,1);
    if (!iswin) {
        if (iscycle) cout << "Draw";
        else cout << "Lose";
    }
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAX = 2e9;
typedef pair<int, int> pi;
int n, m;
vector<vector<int>>g;
bool vis[100003][2];
bool iswin, islose;
vector<int>ans;
void dfs(int u, bool c) {
    if (iswin)return;
    vis[u][c] = 1;
    ans.push_back(u);
    if (g[u].size() == 0) { // if outdegree is 0
        if (c == 1)islose = 1;

        if (c == 0) {
            iswin = 1;
            cout << "Win" << "\n";
            for (int i : ans)cout << i << " ";
            return;
        }
    }
    for (int v : g[u]) {
        int nc = 1 - c;
        if (vis[v][nc]==0)dfs(v, nc);
    }
    if (iswin)return;
    ans.pop_back();
}
int main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> n >> m;
    g.resize(n + 1);
    for (int i = 1; i <= n; i++) {
        int c;
        cin >> c;
        set<int> s;
        for (int j = 0; j < c; j++) {
            int v;
            cin >> v;
            s.insert(v);
        }
        for (int j : s)g[i].push_back(j);
    }
    int s;
    cin >> s;
    dfs(s,1);
    if (!iswin) {
        if (islose) cout << "Lose";
        else cout << "Draw";
    }
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAX = 2e9;
typedef pair<int, int> pi;
int n, m;
vector<vector<int>>g;
int p[(int)1e5 + 3];
bool vis[(int)1e5 + 3][2];
bool iswin, islose;

void dfs(int u,int pu, int c) {
    if (iswin)return;
    if (pu != -1)p[u] = pu;
    vis[u][c] = 1;
    if (g[u].size() == 0) { // if outdegree is 0
        if (c == 1)islose = 1;

        if (c == 0) {
            iswin = 1;
            vector<int>vv;
            while (u != -1) {
                vv.push_back(u);
                u = p[u];
            }
            cout << "Win" << "\n";
            reverse(vv.begin(), vv.end());
            for (int i : vv)cout << i << " ";
            return;
        }

    }
    for (int v : g[u]) {
        if (iswin)return;
        int nc = 1 - c;
        if (vis[v][nc]==0)dfs(v, u, nc);
    }
}
int main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> n >> m;
    g.resize(n + 1);
    memset(p, -1, sizeof(p));
    for (int i = 1; i <= n; i++) {
        int c;
        cin >> c;
        set<int> s;
        for (int j = 0; j < c; j++) {
            int v;
            cin >> v;
            s.insert(v);
        }
        for (int j : s)g[i].push_back(j);
    }
    int s;
    cin >> s;
    dfs(s,-1, 1);
    if (!iswin) {
        if (islose) cout << "Lose";
        else cout << "Draw";
    }
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;
#define ll long long
#define hii cout << "hii" << endl
#define int ll
#define endl '\n'
#define all(s) s.begin(), s.end()

template <class T> ostream& operator << (ostream &os, const vector<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T> ostream& operator << (ostream &os, const set<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T, class S> ostream& operator << (ostream &os, const pair<T, S> &v) { os << v.first << ' ' << v.second; return os; }
template <class T, class S> ostream& operator << (ostream &os, const unordered_map<T, S> &v) { for (auto i : v) os << '(' << i.first << "=>" << i.second << ')' << ' '; return os; }

#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <class Arg1> void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 << endl; }
    template <class Arg1, class... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args) {
        const char* sep = strchr(names + 1, ',');
        cerr.write(names, sep - names) << " : " << arg1 << "  ";
        __f(sep + 1, args...);
    }
#else
#define trace(...) 0
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("avx2,sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS
#endif // ifndef ONLINE_JUDGE

const int N = 3e5 + 5;
const int MAXN = 1e5 + 5;
const int M = 1e5;
const int mod = 998244353;
const int MOD = 998244353;
const int INF = 1e15;
const int LG = 21;

int arr[N];
int n, m;
int s;
vector<int> v[N];
int par[N][2];
bool visited[N][2];
int col[N];
bool iscycle;

void dfs(int sv)
{
	if(col[sv] == 1)
	{
		iscycle = 1;
		return;
	}
	if(col[sv] == 2)
	{
		return;
	}
	col[sv] = 1;
	for(int x : v[sv])
	{
		dfs(x);
	}
	col[sv] = 2;
}

void solve()
{
	cin >> n >> m;
	for(int i = 1; i <= n; i++)
	{
		int sz;
		cin >> sz;
		for(int j = 0; j < sz; j++)
		{
			int b;
			cin >> b;
			v[i].push_back(b);
		}
	}
	cin >> s;
	queue<pair<int, int>> q;
	q.push({s, 0});
	visited[s][0] = 1;
	par[s][0] = -1;
	while(q.size())
	{
		pair<int, int> curr = q.front();
		q.pop();
		for(int x : v[curr.first])
		{
			if(!visited[x][curr.second ^ 1])
			{
				visited[x][curr.second ^ 1] = 1;
				q.push({x, curr.second ^ 1});
				par[x][curr.second ^ 1] = curr.first;
			}
		}
	}
	int tt = 10;
	vector<int> path;
	for(int i = 1; i <= n; i++)
	{
		if(v[i].size() == 0)
		{
			if(visited[i][1])
			{
				int temp = i;
				int curr = 1;
				int tt = 15;
				while(temp != -1 and tt--)
				{
					path.push_back(temp);
					temp = par[temp][curr];
					curr ^= 1;
				}
				cout << "Win" << endl;
				reverse(all(path));
				for(int x : path)
				{
					cout << x << " ";
				}
				return;
			}
		}
	}
	dfs(s);
	if(iscycle)
	{
		cout << "Draw" << endl;
	}
	else
	{
		cout << "Lose" << endl;
	}
}

int32_t main()
{
    ios_base:: sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	#ifndef ONLINE_JUDGE
	    freopen("input.txt", "r", stdin);
	    freopen("output.txt", "w", stdout);
	#endif
	    int t = 1;
	    // cin >> t;
	while(t--)solve();
	return 0;
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;
#define ll long long
#define hii cout << "hii" << endl
#define int ll
#define endl '\n'
#define all(s) s.begin(), s.end()

template <class T> ostream& operator << (ostream &os, const vector<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T> ostream& operator << (ostream &os, const set<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T, class S> ostream& operator << (ostream &os, const pair<T, S> &v) { os << v.first << ' ' << v.second; return os; }
template <class T, class S> ostream& operator << (ostream &os, const unordered_map<T, S> &v) { for (auto i : v) os << '(' << i.first << "=>" << i.second << ')' << ' '; return os; }

#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <class Arg1> void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 << endl; }
    template <class Arg1, class... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args) {
        const char* sep = strchr(names + 1, ',');
        cerr.write(names, sep - names) << " : " << arg1 << "  ";
        __f(sep + 1, args...);
    }
#else
#define trace(...) 0
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("avx2,sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS
#endif // ifndef ONLINE_JUDGE

const int N = 3e5 + 5;
const int MAXN = 1e5 + 5;
const int M = 1e5;
const int mod = 998244353;
const int MOD = 998244353;
const int INF = 1e15;
const int LG = 21;

int arr[N];
int n, m;
int s;
vector<int> v[N];
int par[N][2];
bool visited[N][2];
int col[N];
bool iscycle;

void dfs(int sv)
{
	if(col[sv] == 1)
	{
		iscycle = 1;
		return;
	}
	if(col[sv] == 2)
	{
		return;
	}
	col[sv] = 1;
	for(int x : v[sv])
	{
		dfs(x);
	}
	col[sv] = 2;
}

void solve()
{
	cin >> n >> m;
	for(int i = 1; i <= n; i++)
	{
		int sz;
		cin >> sz;
		for(int j = 0; j < sz; j++)
		{
			int b;
			cin >> b;
			v[i].push_back(b);
		}
	}
	cin >> s;
	queue<pair<int, int>> q;
	q.push({s, 0});
	visited[s][0] = 1;
	par[s][0] = -1;
	while(q.size())
	{
		pair<int, int> curr = q.front();
		q.pop();
		for(int x : v[curr.first])
		{
			if(!visited[x][curr.second ^ 1])
			{
				visited[x][curr.second ^ 1] = 1;
				q.push({x, curr.second ^ 1});
				par[x][curr.second ^ 1] = curr.first;
			}
		}
	}
	int tt = 10;
	vector<int> path;
	for(int i = 1; i <= n; i++)
	{
		if(v[i].size() == 0)
		{
			if(visited[i][1])
			{
				int temp = i;
				int curr = 1;
				while(temp != -1)
				{
					path.push_back(temp);
					temp = par[temp][curr];
					curr ^= 1;
				}
				cout << "Win" << endl;
				reverse(all(path));
				for(int x : path)
				{
					cout << x << " ";
				}
				return;
			}
		}
	}
	dfs(1);
	if(iscycle)
	{
		cout << "Draw" << endl;
	}
	else
	{
		cout << "Lose" << endl;
	}
}

int32_t main()
{
    ios_base:: sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	#ifndef ONLINE_JUDGE
	    freopen("input.txt", "r", stdin);
	    freopen("output.txt", "w", stdout);
	#endif
	    int t = 1;
	    // cin >> t;
	while(t--)solve();
	return 0;
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;
#define ll long long
#define hii cout << "hii" << endl
#define int ll
#define endl '\n'
#define all(s) s.begin(), s.end()

template <class T> ostream& operator << (ostream &os, const vector<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T> ostream& operator << (ostream &os, const set<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T, class S> ostream& operator << (ostream &os, const pair<T, S> &v) { os << v.first << ' ' << v.second; return os; }
template <class T, class S> ostream& operator << (ostream &os, const unordered_map<T, S> &v) { for (auto i : v) os << '(' << i.first << "=>" << i.second << ')' << ' '; return os; }

#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <class Arg1> void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 << endl; }
    template <class Arg1, class... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args) {
        const char* sep = strchr(names + 1, ',');
        cerr.write(names, sep - names) << " : " << arg1 << "  ";
        __f(sep + 1, args...);
    }
#else
#define trace(...) 0
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("avx2,sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS
#endif // ifndef ONLINE_JUDGE

const int N = 3e5 + 5;
const int MAXN = 1e5 + 5;
const int M = 1e5;
const int mod = 998244353;
const int MOD = 998244353;
const int INF = 1e15;
const int LG = 21;

int arr[N];
int n, m;
int s;
vector<int> v[N];
int par[N][2];
bool visited[N][2];
int col[N];
bool iscycle;

void dfs(int sv)
{
	if(col[sv] == 1)
	{
		iscycle = 1;
		return;
	}
	if(col[sv] == 2)
	{
		return;
	}
	col[sv] = 1;
	for(int x : v[sv])
	{
		dfs(x);
	}
	col[sv] = 2;
}

void solve()
{
	cin >> n >> m;
	for(int i = 1; i <= n; i++)
	{
		int sz;
		cin >> sz;
		for(int j = 0; j < sz; j++)
		{
			int b;
			cin >> b;
			v[i].push_back(b);
		}
	}
	cin >> s;
	queue<pair<int, int>> q;
	q.push({s, 0});
	visited[s][0] = 1;
	par[s][0] = -1;
	while(q.size())
	{
		pair<int, int> curr = q.front();
		q.pop();
		for(int x : v[curr.first])
		{
			if(!visited[x][curr.second ^ 1])
			{
				visited[x][curr.second ^ 1] = 1;
				q.push({x, curr.second ^ 1});
				par[x][curr.second ^ 1] = curr.first;
			}
		}
	}
	int tt = 10;
	vector<int> path;
	for(int i = 1; i <= n; i++)
	{
		if(v[i].size() == 0)
		{
			if(visited[i][1])
			{
				int temp = i;
				int curr = 1;
				while(temp != -1)
				{
					path.push_back(temp);
					temp = par[temp][curr];
					curr ^= 1;
				}
				cout << "Win" << endl;
				reverse(all(path));
				for(int x : path)
				{
					cout << x << " ";
				}
				return;
			}
		}
	}
	dfs(s);
	if(iscycle)
	{
		cout << "Draw" << endl;
	}
	else
	{
		cout << "Lose" << endl;
	}
}

int32_t main()
{
    ios_base:: sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	#ifndef ONLINE_JUDGE
	    freopen("input.txt", "r", stdin);
	    freopen("output.txt", "w", stdout);
	#endif
	    int t = 1;
	    // cin >> t;
	while(t--)solve();
	return 0;
}


#include<bits/stdc++.h>

#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define forn(i,o,n) for(int i=o;i<n;i++)
#define int long long
#define endl "\n"
#define mod 1000000007
#define double long double
#define pb push_back
#define mk make_pair
#define swap(x,y) (x^=y^=x^=y)
#define TT int ttt;cin>>ttt;while(ttt--)

using namespace std;

int gcd(int a, int b){
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
bool isPrime(int n){
    if(n < 2)
        return 0;
    if(n < 4)
        return 1;
    if(n % 2 == 0 or n % 3 == 0)
        return 0;
    for(int i = 5; i*i <= n; i += 6)
        if(n % i == 0 or n % (i+2) == 0)
            return 0;
    return 1;
}
int modexpo(int x,int p){
    int res = 1;
    x = x%mod;
    while(p){
        if(p%2)
            res = res * x;
        p >>= 1;
        x = x*x % mod;
        res %= mod;
    }
    return res;
}

int max(int a,int b){
    if(a>b){
        return a;
    }
    return b;
}

int min(int a,int b){
    if(a<b){
        return a;
    }
    return b;
}
const int N = 200005;

int outD[N],dist[N],pred[N];
vector<int>g[N];
int st;
int n,m;
int cycle = 0;

vector<int>ans;
void dfs(int v,int vis[],int ret[]){
    if(ans.size()>0){
        return ;
    }
    vis[v]++;
    ret[v]=1;
    if(dist[v]%2==1 && outD[v]==0){
        int x = v;
        while(x!=-1){
            cout<<x<<endl;
            ans.pb(x);
            x=pred[x];
        }
        return;
    }
    for(int i=0;i<g[v].size();i++){
        if(ret[g[v][i]]==1){
            cycle=1;
        }
        if(vis[g[v][i]]<2){
            dist[g[v][i]]=dist[v]+1;
            pred[g[v][i]]=v;
            dfs(g[v][i],vis,ret);
        }
    }
    ret[v]=0;
}
int32_t main(){
    IOS
    memset(outD,0,sizeof(outD));
    memset(pred,-1,sizeof(pred));
    cin>>n>>m;
    for(int i=1;i<=n;i++){
        int k;
        cin>>k;
        outD[i]=k;
        for(int j=0;j<k;j++){
            int v;
            cin>>v;
            g[i].pb(v);
        }
    }

    cin>>st;

    int vis[n+1];
    int ret[n+1];
    for(int i=0;i<g[st].size();i++){
        if(outD[g[st][i]]==0){
            cout<<"Win"<<endl;
            cout<<st<<" "<<g[st][i]<<endl;
            return 0;
        }
    }
    memset(vis,0,sizeof(vis));
    memset(ret,0,sizeof(ret));
    dfs(st,vis,ret);
    if(ans.size()==0 && cycle==0){
        cout<<"Lose"<<endl;
    }
    else if(ans.size()==0 && cycle==1){
        cout<<"Draw"<<endl;
    }
    else{
        cout<<"Win"<<endl;
        reverse(ans.begin(),ans.end());
        for(int i=0;i<ans.size();i++){
            cout<<ans[i]<<" ";
        }
        cout<<endl;
    }
}


#include<bits/stdc++.h>

#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define forn(i,o,n) for(int i=o;i<n;i++)
#define int long long
#define endl "\n"
#define mod 1000000007
#define double long double
#define pb push_back
#define mk make_pair
#define swap(x,y) (x^=y^=x^=y)
#define TT int ttt;cin>>ttt;while(ttt--)

using namespace std;

int gcd(int a, int b){
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
bool isPrime(int n){
    if(n < 2)
        return 0;
    if(n < 4)
        return 1;
    if(n % 2 == 0 or n % 3 == 0)
        return 0;
    for(int i = 5; i*i <= n; i += 6)
        if(n % i == 0 or n % (i+2) == 0)
            return 0;
    return 1;
}
int modexpo(int x,int p){
    int res = 1;
    x = x%mod;
    while(p){
        if(p%2)
            res = res * x;
        p >>= 1;
        x = x*x % mod;
        res %= mod;
    }
    return res;
}

int max(int a,int b){
    if(a>b){
        return a;
    }
    return b;
}

int min(int a,int b){
    if(a<b){
        return a;
    }
    return b;
}
const int N = 200005;

int outD[N],dist[N],pred[N];
vector<int>g[N];
int st;
int n,m;
int cycle = 0;

vector<int>ans;
void dfs(int v,int vis[],int ret[]){
    if(ans.size()>0){
        return ;
    }
    vis[v]++;
    ret[v]=1;
    if(dist[v]%2==1 && outD[v]==0){
        int x = v;
        while(x!=-1){
            //cout<<x<<endl;
            ans.pb(x);
            x=pred[x];
        }
        return;
    }
    for(int i=0;i<g[v].size();i++){
        if(ret[g[v][i]]==1){
            cycle=1;
        }
        if(vis[g[v][i]]<2){
            dist[g[v][i]]=dist[v]+1;
            pred[g[v][i]]=v;
            dfs(g[v][i],vis,ret);
        }
    }
    ret[v]=0;
}
int32_t main(){
    IOS
    memset(outD,0,sizeof(outD));
    memset(pred,-1,sizeof(pred));
    cin>>n>>m;
    for(int i=1;i<=n;i++){
        int k;
        cin>>k;
        outD[i]=k;
        for(int j=0;j<k;j++){
            int v;
            cin>>v;
            g[i].pb(v);
        }
    }

    cin>>st;

    int vis[n+1];
    int ret[n+1];
    for(int i=0;i<g[st].size();i++){
        if(outD[g[st][i]]==0){
            cout<<"Win"<<endl;
            cout<<st<<" "<<g[st][i]<<endl;
            return 0;
        }
    }
    memset(vis,0,sizeof(vis));
    memset(ret,0,sizeof(ret));
    dfs(st,vis,ret);
    if(ans.size()==0 && cycle==0){
        cout<<"Lose"<<endl;
    }
    else if(ans.size()==0 && cycle==1){
        cout<<"Draw"<<endl;
    }
    else{
        cout<<"Win"<<endl;
        reverse(ans.begin(),ans.end());
        for(int i=0;i<ans.size();i++){
            cout<<ans[i]<<" ";
        }
        cout<<endl;
    }
}


#include<bits/stdc++.h>

#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define forn(i,o,n) for(int i=o;i<n;i++)
#define int long long
#define endl "\n"
#define mod 1000000007
#define double long double
#define pb push_back
#define mk make_pair
#define swap(x,y) (x^=y^=x^=y)
#define TT int ttt;cin>>ttt;while(ttt--)

using namespace std;

int gcd(int a, int b){
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
bool isPrime(int n){
    if(n < 2)
        return 0;
    if(n < 4)
        return 1;
    if(n % 2 == 0 or n % 3 == 0)
        return 0;
    for(int i = 5; i*i <= n; i += 6)
        if(n % i == 0 or n % (i+2) == 0)
            return 0;
    return 1;
}
int modexpo(int x,int p){
    int res = 1;
    x = x%mod;
    while(p){
        if(p%2)
            res = res * x;
        p >>= 1;
        x = x*x % mod;
        res %= mod;
    }
    return res;
}

int max(int a,int b){
    if(a>b){
        return a;
    }
    return b;
}

int min(int a,int b){
    if(a<b){
        return a;
    }
    return b;
}
const int N = 200005;

int inD[N],outD[N],dist[N],pred[N];
vector<int>g[N];
int st;
int n,m;
int cycle = 0;

void dfs(int v,int vis[],int ret[]){
    if(cycle==1){
        return ;
    }
    vis[v]=1;
    ret[v]=1;
    for(int i=0;i<g[v].size();i++){
        if(ret[g[v][i]]==1){
            cycle=1;
            return;
        }
        if(vis[g[v][i]]==0){
            dfs(g[v][i],vis,ret);
        }
    }
    ret[v]=0;
}

vector<int>ans;
void bfs(int v,int vis[]){
    vis[v]=1;
    queue<int>q;
    q.push(v);
    while(!q.empty()){
        int x = q.front();
        q.pop();
        if(dist[x]%2==1 && outD[x]==0){
            while(x!=-1){
                ans.pb(x);
                x=pred[x];
            }
            break;
        }
        for(int i=0;i<g[x].size();i++){
            if(true){
                dist[g[x][i]]=dist[x]+1;
                pred[g[x][i]]=x;
                q.push(g[x][i]);
            }
        }
    }
}
int32_t main(){
    IOS
    memset(inD,0,sizeof(inD));
    memset(outD,0,sizeof(outD));
    memset(pred,-1,sizeof(pred));
    cin>>n>>m;
    for(int i=1;i<=n;i++){
        int k;
        cin>>k;
        outD[i]=k;
        for(int j=0;j<k;j++){
            int v;
            cin>>v;
            g[i].pb(v);
            inD[v]++;
        }
    }

    cin>>st;

    int vis[n+1];
    int ret[n+1];

    memset(vis,0,sizeof(vis));
    memset(ret,0,sizeof(ret));
    dfs(st,vis,ret);
    memset(vis,0,sizeof(vis));
    memset(ret,0,sizeof(ret));

    memset(dist,0,sizeof(dist));
    ans.clear();
    if(cycle==1){
        cout<<"Draw"<<endl;
        return 0;
    }
    bfs(st,vis);
    if(ans.size()==0){
        cout<<"Lose"<<endl;
    }
    else{
        cout<<"Win"<<endl;
        reverse(ans.begin(),ans.end());
        for(int i=0;i<ans.size();i++){
            cout<<ans[i]<<" ";
        }
        cout<<endl;
    }
}


#include<bits/stdc++.h>

#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define forn(i,o,n) for(int i=o;i<n;i++)
#define int long long
#define endl "\n"
#define mod 1000000007
#define double long double
#define pb push_back
#define mk make_pair
#define swap(x,y) (x^=y^=x^=y)
#define TT int ttt;cin>>ttt;while(ttt--)

using namespace std;

int gcd(int a, int b){
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
bool isPrime(int n){
    if(n < 2)
        return 0;
    if(n < 4)
        return 1;
    if(n % 2 == 0 or n % 3 == 0)
        return 0;
    for(int i = 5; i*i <= n; i += 6)
        if(n % i == 0 or n % (i+2) == 0)
            return 0;
    return 1;
}
int modexpo(int x,int p){
    int res = 1;
    x = x%mod;
    while(p){
        if(p%2)
            res = res * x;
        p >>= 1;
        x = x*x % mod;
        res %= mod;
    }
    return res;
}

int max(int a,int b){
    if(a>b){
        return a;
    }
    return b;
}

int min(int a,int b){
    if(a<b){
        return a;
    }
    return b;
}
const int N = 200005;

int inD[N],outD[N],dist[N],pred[N];
vector<int>g[N];
int st;
int n,m;
int cycle = 0;

vector<int>ans;
void dfs(int v,int vis[],int ret[]){
    if(ans.size()>0){
        return ;
    }
    vis[v]++;
    ret[v]=1;
    if(dist[v]%2==1 && outD[v]==0){
        int x = v;
        while(x!=-1){
            ans.pb(x);
            x=pred[x];
        }
        return;
    }
    for(int i=0;i<g[v].size();i++){
        if(ret[g[v][i]]==1){
            cycle=1;
        }
        if(vis[g[v][i]]<2){
            dist[g[v][i]]=dist[v]+1;
            pred[g[v][i]]=v;
            dfs(g[v][i],vis,ret);
        }
    }
    ret[v]=0;
}

vector<int>prob;
vector<int>en;
void bfs(int v,int vis[],int ret[]){
    vis[v]=1;
    queue<int>q;
    q.push(v);
    while(!q.empty()){
        int x = q.front();
        ret[x]=1;
        q.pop();
        if(dist[x]%2==1 && outD[x]==0){
            while(x!=-1){
                ans.pb(x);
                x=pred[x];
            }
            break;
        }
        if(outD[x]==0 && dist[x]%2==0){
            en.pb(x);
        }
        for(int i=0;i<g[x].size();i++){
            if(ret[g[x][i]]==0){
                dist[g[x][i]]=dist[x]+1;
                pred[g[x][i]]=x;
                q.push(g[x][i]);
            }
            else{
                if(dist[x]%2==1){
                    prob.pb(x);
                }
            }
        }
    }
}
int32_t main(){
    IOS
    memset(inD,0,sizeof(inD));
    memset(outD,0,sizeof(outD));
    memset(pred,-1,sizeof(pred));
    cin>>n>>m;
    for(int i=1;i<=n;i++){
        int k;
        cin>>k;
        outD[i]=k;
        for(int j=0;j<k;j++){
            int v;
            cin>>v;
            g[i].pb(v);
            inD[v]++;
        }
    }

    cin>>st;

    int vis[n+1];
    int ret[n+1];

    memset(vis,0,sizeof(vis));
    memset(ret,0,sizeof(ret));
    dfs(st,vis,ret);
    memset(vis,0,sizeof(vis));
    memset(ret,0,sizeof(ret));

    memset(dist,0,sizeof(dist));
    //ans.clear();
    //bfs(st,vis,ret);
    if(ans.size()==0 && cycle==0){
        cout<<"Lose"<<endl;
    }
    else if(ans.size()==0 && cycle==1){
        cout<<"Draw"<<endl;
    }
    else{
        cout<<"Win"<<endl;
        reverse(ans.begin(),ans.end());
        for(int i=0;i<ans.size();i++){
            cout<<ans[i]<<" ";
        }
        cout<<endl;
    }
}


#include<bits/stdc++.h>

#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define forn(i,o,n) for(int i=o;i<n;i++)
#define int long long
#define endl "\n"
#define mod 1000000007
#define double long double
#define pb push_back
#define mk make_pair
#define swap(x,y) (x^=y^=x^=y)
#define TT int ttt;cin>>ttt;while(ttt--)

using namespace std;

int gcd(int a, int b){
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
bool isPrime(int n){
    if(n < 2)
        return 0;
    if(n < 4)
        return 1;
    if(n % 2 == 0 or n % 3 == 0)
        return 0;
    for(int i = 5; i*i <= n; i += 6)
        if(n % i == 0 or n % (i+2) == 0)
            return 0;
    return 1;
}
int modexpo(int x,int p){
    int res = 1;
    x = x%mod;
    while(p){
        if(p%2)
            res = res * x;
        p >>= 1;
        x = x*x % mod;
        res %= mod;
    }
    return res;
}

int max(int a,int b){
    if(a>b){
        return a;
    }
    return b;
}

int min(int a,int b){
    if(a<b){
        return a;
    }
    return b;
}
const int N = 200005;

int inD[N],outD[N],dist[N],pred[N];
vector<int>g[N];
int st;
int n,m;
int cycle = 0;

void dfs(int v,int vis[],int ret[]){
    if(cycle==1){
        return ;
    }
    vis[v]=1;
    ret[v]=1;
    for(int i=0;i<g[v].size();i++){
        if(ret[g[v][i]]==1){
            cycle=1;
            return;
        }
        if(vis[g[v][i]]==0){
            dfs(g[v][i],vis,ret);
        }
    }
    ret[v]=0;
}

vector<int>ans;
void bfs(int v,int vis[],int ret[]){
    vis[v]=1;
    queue<int>q;
    q.push(v);
    while(!q.empty()){
        int x = q.front();
        ret[x]=1;
        q.pop();
        if(dist[x]%2==1 && outD[x]==0){
            while(x!=-1){
                ans.pb(x);
                x=pred[x];
            }
            break;
        }
        for(int i=0;i<g[x].size();i++){
            if(ret[g[x][i]]==0){
                dist[g[x][i]]=dist[x]+1;
                pred[g[x][i]]=x;
                q.push(g[x][i]);
            }
        }
    }
}
int32_t main(){
    IOS
    memset(inD,0,sizeof(inD));
    memset(outD,0,sizeof(outD));
    memset(pred,-1,sizeof(pred));
    cin>>n>>m;
    for(int i=1;i<=n;i++){
        int k;
        cin>>k;
        outD[i]=k;
        for(int j=0;j<k;j++){
            int v;
            cin>>v;
            g[i].pb(v);
            inD[v]++;
        }
    }

    cin>>st;

    int vis[n+1];
    int ret[n+1];

    memset(vis,0,sizeof(vis));
    memset(ret,0,sizeof(ret));
    dfs(st,vis,ret);
    memset(vis,0,sizeof(vis));
    memset(ret,0,sizeof(ret));

    memset(dist,0,sizeof(dist));
    ans.clear();
    bfs(st,vis,ret);
    if(ans.size()==0 && cycle==0){
        cout<<"Lose"<<endl;
    }
    else if(ans.size()==0 && cycle==1){
        cout<<"Draw"<<endl;
    }
    else{
        cout<<"Win"<<endl;
        reverse(ans.begin(),ans.end());
        for(int i=0;i<ans.size();i++){
            cout<<ans[i]<<" ";
        }
        cout<<endl;
    }
}


#include<bits/stdc++.h>

#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define forn(i,o,n) for(int i=o;i<n;i++)
#define int long long
#define endl "\n"
#define mod 1000000007
#define double long double
#define pb push_back
#define mk make_pair
#define swap(x,y) (x^=y^=x^=y)
#define TT int ttt;cin>>ttt;while(ttt--)

using namespace std;

int gcd(int a, int b){
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
bool isPrime(int n){
    if(n < 2)
        return 0;
    if(n < 4)
        return 1;
    if(n % 2 == 0 or n % 3 == 0)
        return 0;
    for(int i = 5; i*i <= n; i += 6)
        if(n % i == 0 or n % (i+2) == 0)
            return 0;
    return 1;
}
int modexpo(int x,int p){
    int res = 1;
    x = x%mod;
    while(p){
        if(p%2)
            res = res * x;
        p >>= 1;
        x = x*x % mod;
        res %= mod;
    }
    return res;
}

int max(int a,int b){
    if(a>b){
        return a;
    }
    return b;
}

int min(int a,int b){
    if(a<b){
        return a;
    }
    return b;
}

const int N = 200005;
vector<int>g[N];
int vis[N];
int ret[N];
int n,m;
int cycle=0;
vector<int>ans;
void dfs(int v,int cnt){
    vis[v]++;
    ret[v]=1;
    ans.pb(v);
    if(g[v].size()==0 && cnt%2==1){
        cout<<"Win"<<endl;
        for(int i=0;i<ans.size();i++){
            cout<<ans[i]<<" ";
        }
        cout<<endl;
        exit(0);
    }
    for(int i=0;i<g[v].size();i++){
        if(ret[g[v][i]]==1){
            cycle=1;
        }
        if(vis[g[v][i]]<2){
            dfs(g[v][i],cnt+1);
        }
    }
    ans.pop_back();
    ret[v]=0;
}
int32_t main(){
    IOS
    cin>>n>>m;
    for(int i=1;i<=n;i++){
        int t;
        cin>>t;
        while(t--){
            int x;
            cin>>x;
            g[i].pb(x);
        }
    }
    memset(vis,0,sizeof(vis));
    memset(ret,0,sizeof(ret));
    int st;
    cin>>st;
    dfs(st,0);
    if(cycle==1){
        cout<<"Draw"<<endl;
        return 0;
    }
    cout<<"Lose"<<endl;
}


#include<bits/stdc++.h>

#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define forn(i,o,n) for(int i=o;i<n;i++)
#define int long long
#define endl "\n"
#define mod 1000000007
#define double long double
#define pb push_back
#define mk make_pair
#define swap(x,y) (x^=y^=x^=y)
#define TT int ttt;cin>>ttt;while(ttt--)

using namespace std;

int gcd(int a, int b){
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
bool isPrime(int n){
    if(n < 2)
        return 0;
    if(n < 4)
        return 1;
    if(n % 2 == 0 or n % 3 == 0)
        return 0;
    for(int i = 5; i*i <= n; i += 6)
        if(n % i == 0 or n % (i+2) == 0)
            return 0;
    return 1;
}
int modexpo(int x,int p){
    int res = 1;
    x = x%mod;
    while(p){
        if(p%2)
            res = res * x;
        p >>= 1;
        x = x*x % mod;
        res %= mod;
    }
    return res;
}

int max(int a,int b){
    if(a>b){
        return a;
    }
    return b;
}

int min(int a,int b){
    if(a<b){
        return a;
    }
    return b;
}
const int N = 200005;

int inD[N],outD[N],dist[N],pred[N];
vector<int>g[N];
int st;
int n,m;
int cycle = 0;

vector<int>ans;
void dfs(int v,int vis[],int ret[]){
    if(ans.size()>0){
        return ;
    }
    vis[v]=1;
    ret[v]=1;
    if(dist[v]%2==1 && outD[v]==0){
        int x = v;
        while(x!=-1){
            ans.pb(x);
            x=pred[x];
        }
        return;
    }
    for(int i=0;i<g[v].size();i++){
        if(ret[g[v][i]]==1){
            cycle=1;
            continue;
        }
        dist[g[v][i]]=dist[v]+1;
        pred[g[v][i]]=v;
        dfs(g[v][i],vis,ret);
    }
    ret[v]=0;
}

vector<int>prob;
vector<int>en;
void bfs(int v,int vis[],int ret[]){
    vis[v]=1;
    queue<int>q;
    q.push(v);
    while(!q.empty()){
        int x = q.front();
        ret[x]=1;
        q.pop();
        if(dist[x]%2==1 && outD[x]==0){
            while(x!=-1){
                ans.pb(x);
                x=pred[x];
            }
            break;
        }
        if(outD[x]==0 && dist[x]%2==0){
            en.pb(x);
        }
        for(int i=0;i<g[x].size();i++){
            if(ret[g[x][i]]==0){
                dist[g[x][i]]=dist[x]+1;
                pred[g[x][i]]=x;
                q.push(g[x][i]);
            }
            else{
                if(dist[x]%2==1){
                    prob.pb(x);
                }
            }
        }
    }
}
int32_t main(){
    IOS
    memset(inD,0,sizeof(inD));
    memset(outD,0,sizeof(outD));
    memset(pred,-1,sizeof(pred));
    cin>>n>>m;
    for(int i=1;i<=n;i++){
        int k;
        cin>>k;
        outD[i]=k;
        for(int j=0;j<k;j++){
            int v;
            cin>>v;
            g[i].pb(v);
            inD[v]++;
        }
    }

    cin>>st;

    int vis[n+1];
    int ret[n+1];

    memset(vis,0,sizeof(vis));
    memset(ret,0,sizeof(ret));
    dfs(st,vis,ret);
    memset(vis,0,sizeof(vis));
    memset(ret,0,sizeof(ret));

    memset(dist,0,sizeof(dist));
    //ans.clear();
    //bfs(st,vis,ret);
    if(ans.size()==0 && cycle==0){
        cout<<"Lose"<<endl;
    }
    else if(ans.size()==0 && cycle==1){
        cout<<"Draw"<<endl;
    }
    else{
        cout<<"Win"<<endl;
        reverse(ans.begin(),ans.end());
        for(int i=0;i<ans.size();i++){
            cout<<ans[i]<<" ";
        }
        cout<<endl;
    }
}


#include<bits/stdc++.h>

#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define forn(i,o,n) for(int i=o;i<n;i++)
#define int long long
#define endl "\n"
#define mod 1000000007
#define double long double
#define pb push_back
#define mk make_pair
#define swap(x,y) (x^=y^=x^=y)
#define TT int ttt;cin>>ttt;while(ttt--)

using namespace std;

int gcd(int a, int b){
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
bool isPrime(int n){
    if(n < 2)
        return 0;
    if(n < 4)
        return 1;
    if(n % 2 == 0 or n % 3 == 0)
        return 0;
    for(int i = 5; i*i <= n; i += 6)
        if(n % i == 0 or n % (i+2) == 0)
            return 0;
    return 1;
}
int modexpo(int x,int p){
    int res = 1;
    x = x%mod;
    while(p){
        if(p%2)
            res = res * x;
        p >>= 1;
        x = x*x % mod;
        res %= mod;
    }
    return res;
}

int max(int a,int b){
    if(a>b){
        return a;
    }
    return b;
}

int min(int a,int b){
    if(a<b){
        return a;
    }
    return b;
}
const int N = 200005;

int outD[N],dist[N],pred[N];
vector<int>g[N];
int st;
int n,m;
int cycle = 0;

vector<int>ans;
void dfs(int v,int vis[],int ret[]){
    if(ans.size()>0){
        return ;
    }
    vis[v]++;
    ret[v]=1;
    if(dist[v]%2==1 && outD[v]==0){
        int x = v;
        while(x!=-1){
            ans.pb(x);
            x=pred[x];
        }
        return;
    }
    for(int i=0;i<g[v].size();i++){
        if(ret[g[v][i]]==1){
            cycle=1;
        }
        if(vis[g[v][i]]<2){
            dist[g[v][i]]=dist[v]+1;
            pred[g[v][i]]=v;
            dfs(g[v][i],vis,ret);
        }
    }
    ret[v]=0;
}
int32_t main(){
    IOS
    memset(outD,0,sizeof(outD));
    memset(pred,-1,sizeof(pred));
    cin>>n>>m;
    for(int i=1;i<=n;i++){
        int k;
        cin>>k;
        outD[i]=k;
        for(int j=0;j<k;j++){
            int v;
            cin>>v;
            g[i].pb(v);
        }
    }

    cin>>st;

    int vis[n+1];
    int ret[n+1];

    memset(vis,0,sizeof(vis));
    memset(ret,0,sizeof(ret));
    dfs(st,vis,ret);
    if(ans.size()==0 && cycle==0){
        cout<<"Lose"<<endl;
    }
    else if(ans.size()==0 && cycle==1){
        cout<<"Draw"<<endl;
    }
    else{
        cout<<"Win"<<endl;
        reverse(ans.begin(),ans.end());
        for(int i=0;i<ans.size();i++){
            cout<<ans[i]<<" ";
        }
        cout<<endl;
    }
}


#include<iostream>
#include<vector>
#include<queue>
#include<cstring>
#include<algorithm>
using namespace std;
const int MAXN=1e5+10;
vector<int>G[MAXN],ans;
int n,m;
int s;
int flag=0;
int vis[MAXN][2],to[MAXN][2],loop[MAXN];
int cnt=0;
void dfs(int w,int u,int d)
{
    //cout<<1<<endl;
    if(vis[u][d]==1) return;
    vis[u][d]=1;
    to[u][d]=w;
    for(auto v:G[u])
        dfs(u,v,d^1);
}
int judge(int u)
{
    loop[u]=1;
    int flag=0;
    for(auto v:G[u])
    {
        if(loop[v]==1)
            flag=1;
        else if(loop[v]==0)
            flag=judge(v);
        if(flag)
            return 1;
    }
    loop[u]=2;
    return 0;
}
int main()
{
    memset(vis,0,sizeof(vis));
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++)
    {
        int t;
        scanf("%d",&t);
        while(t--)
        {
            int x;
            scanf("%d",&x);
            G[i].push_back(x);
        }
    }
    /*for(int i=1;i<=n;i++)
    {
        for(int j=0;j<2;j++)
            cout<<G[i][j]<<" ";
        cout<<endl;
    }*/
    scanf("%d",&s);
    //cout<<2<<endl;
    //cout<<s<<endl;
    dfs(0,s,0);
    //cout<<2<<endl;
    for(int i=1;i<=n;i++)
    {
        //cout<<1<<endl;
        if(vis[i][1]&&G[i].size()==0)
        {
            int u=i;
            int d=1;
            //cout<<u<<endl;
            ans.push_back(u);
            //cout<<u<<endl;
            while(to[u][d]!=0)
            {
                //cout<<to[u][d]<<" ";
                ans.push_back(to[u][d]);
                u=to[u][d];
                d^=1;
            }
            cout<<"Win"<<endl;
            for(int i=ans.size()-1;i>0;i--)
                cout<<ans[i]<<" ";
            cout<<ans[0]<<endl;
            return 0;
        }
    }
    if(judge(s)) cout<<"Draw"<<endl;
    else cout<<"Lose"<<endl;
    return 0;
}


#include<iostream>
#include<vector>
#include<queue>
#include<cstring>
#include<algorithm>
using namespace std;
int n,m;
int s;
int flag=0;
vector<int>G[10010];
int line[10010];
int cnt=0;
void dfs(int u)
{
    if(flag) return ;
    if(!G[u].size()||cnt==105)
    {
        line[cnt++]=u;
        flag=1;
        return;
    }
    line[cnt++]=u;
    for(auto v:G[u])
    {
        //cout<<"u="<<u<<"v="<<v<<endl;
        dfs(v);
    }
}
int main()
{
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++)
    {
        int t;
        scanf("%d",&t);
        while(t--)
        {
            int x;
            scanf("%d",&x);
            G[i].push_back(x);
        }
    }
    /*for(int i=1;i<=n;i++)
    {
        for(int j=0;j<2;j++)
            cout<<G[i][j]<<" ";
        cout<<endl;
    }*/
    scanf("%d",&s);
    dfs(s);
    if(cnt==106)
        cout<<"Draw"<<endl;
    else
    {
        if(cnt%2==0)
        {
            cout<<"Win"<<endl;
            for(int i=0;i<cnt-1;i++)
                cout<<line[i]<<" ";
            cout<<line[cnt-1]<<endl;
        }
        else
            cout<<"Lose"<<endl;
    }
    return 0;
}


#include<iostream>
#include<vector>
#include<queue>
#include<cstring>
#include<algorithm>
using namespace std;
int n,m;
int s;
int flag=0;
vector<int>G[20010];
int line[110];
int cnt=0;
void dfs(int u)
{
    if(flag) return ;
    if(!G[u].size()||cnt==105)
    {
        line[cnt++]=u;
        flag=1;
        return;
    }
    line[cnt++]=u;
    for(auto v:G[u])
    {
        //cout<<"u="<<u<<"v="<<v<<endl;
        dfs(v);
    }
}
int main()
{
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++)
    {
        int t;
        scanf("%d",&t);
        while(t--)
        {
            int x;
            scanf("%d",&x);
            G[i].push_back(x);
        }
    }
    /*for(int i=1;i<=n;i++)
    {
        for(int j=0;j<2;j++)
            cout<<G[i][j]<<" ";
        cout<<endl;
    }*/
    scanf("%d",&s);
    dfs(s);
    if(cnt==106)
        cout<<"Draw"<<endl;
    else
    {
        if(cnt%2==0)
        {
            cout<<"Win"<<endl;
            for(int i=0;i<cnt-1;i++)
                cout<<line[i]<<" ";
            cout<<line[cnt-1]<<endl;
        }
        else
            cout<<"Lose"<<endl;
    }
    return 0;
}


//
//  main.cpp
//  Codeforces Round #467 (Div. 2) D
//
//  Created by Songjy on 18/6/6.
//  Copyright © 2018年 Songyj. All rights reserved.
//

#include <bits/stdc++.h>

using namespace std;

const int maxn=1e5+100;

vector<int> g[maxn];
bool st[maxn][2];
int vis[maxn];

int main(int argc, const char * argv[]) {

    int n,m,s;
    cin>>n>>m;
    for (int i=0; i<n; ++i) {
        int t;
        cin>>t;
        for (int j=0; j<t; ++j) {
            int v;
            cin>>v;
            --v;
            g[i].push_back(v);
        }
    }
    cin>>s;
    --s;

    vector<int> ans;
    bool ishas=0;

    function<bool(int,int)> dfs=[&](int u,int flag){
       // cout<<u<<" "<<flag<<endl;
        st[u][flag]=1;
        if (!g[u].size()&&flag) {
            ans.push_back(u+1);
            return true;
        }
        vis[u]=1;
        for(int i:g[u]){
            if(vis[i])
                ishas=1;
            if (st[i][!flag]) {
                continue;
            }else{
                if(dfs(i,!flag)){
                    ans.push_back(u+1);
                    return true;
                }
            }
        }
        vis[u]=-1;
        return false;
    };

    if (dfs(s,0)) {
        cout<<"Win"<<endl;
        reverse(ans.begin(),ans.end());
        for (int i:ans) {
            cout<<i<<" ";
        }
        cout<<endl;
    }else if(ishas){
        cout<<"Draw"<<endl;
    }else
        cout<<"Lose"<<endl;
    return 0;
}


//
//  main.cpp
//  Codeforces Round #467 (Div. 2) D
//
//  Created by Songjy on 18/6/6.
//  Copyright © 2018年 Songyj. All rights reserved.
//

#include <bits/stdc++.h>

using namespace std;

const int maxn=1e5+100;

vector<int> g[maxn];
bool st[maxn][2];
bool vis[maxn];

int main(int argc, const char * argv[]) {

    int n,m,s;
    cin>>n>>m;
    for (int i=0; i<n; ++i) {
        int t;
        cin>>t;
        for (int j=0; j<t; ++j) {
            int v;
            cin>>v;
            --v;
            g[i].push_back(v);
        }
    }
    cin>>s;
    --s;

    vector<int> ans;
    bool ishas=0;

    function<bool(int,int)> dfs=[&](int u,int flag){
      //  cout<<u<<" "<<flag<<endl;
        st[u][flag]=1;
        if (!g[u].size()&&flag) {
            ans.push_back(u+1);
            return true;
        }
        for(int i:g[u]){
            if(st[i][0]||st[i][1])
                ishas=1;
            if (st[i][!flag]) {
                continue;
            }else{
                if(dfs(i,!flag)){
                    ans.push_back(u+1);
                    return true;
                }
            }
        }
        return false;
    };

    if (dfs(s,0)) {
        cout<<"Win"<<endl;
        reverse(ans.begin(),ans.end());
        for (int i:ans) {
            cout<<i<<" ";
        }
        cout<<endl;
    }else if(ishas){
        cout<<"Draw"<<endl;
    }else
        cout<<"Lose"<<endl;
    return 0;
}


//
//  main.cpp
//  Codeforces Round #467 (Div. 2) D
//
//  Created by Songjy on 18/6/6.
//  Copyright © 2018年 Songyj. All rights reserved.
//

#include <bits/stdc++.h>

using namespace std;

const int maxn=1e5+100;

vector<int> g[maxn];
bool st[maxn][2];
int vis[maxn];

int main(int argc, const char * argv[]) {

    ios::sync_with_stdio(false);
    int n,m,s;
    cin>>n>>m;
    for (int i=0; i<n; ++i) {
        int t;
        cin>>t;
        for (int j=0; j<t; ++j) {
            int v;
            cin>>v;
            --v;
            g[i].push_back(v);
        }
    }
    cin>>s;
    --s;

    vector<int> ans;
    bool ishas=0;

    function<bool(int,int)> dfs=[&](int u,int flag){
       // cout<<u<<" "<<flag<<endl;
        st[u][flag]=1;
        if (!g[u].size()&&flag) {
            ans.push_back(u+1);
            return true;
        }
        vis[u]=1;
        for(int i:g[u]){
            if(vis[i]==1)
                ishas=1;
            if (st[i][!flag]) {
                continue;
            }else{
                if(dfs(i,!flag)){
                    ans.push_back(u+1);
                    return true;
                }
            }
        }
        vis[u]=-1;
        return false;
    };

    if (dfs(s,0)) {
        cout<<"Win"<<endl;
        reverse(ans.begin(),ans.end());
        for (int i:ans) {
            cout<<i<<" ";
        }
        cout<<endl;
    }else if(ishas){
        cout<<"Draw"<<endl;
    }else
        cout<<"Lose"<<endl;
    return 0;
}