#include <cstdio>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <iterator>
#include <list>
#include <set>
#include <queue>
#include <numeric>
#include <cstdlib>
#include <ctime>
#include <climits>

using namespace std;

typedef long long lli;
typedef long li;

const lli INFLL = (lli)2e18;
const li INF = (li)2e9, M = 21;

struct Friend
{
	li x, k, mask;
	Friend (li x, li k, li mask) : x(x), k(k), mask(mask) {}
	bool operator < (const Friend &f) const
	{
		return k < f.k;
	}
	bool operator < (li x) const
	{
		return k < x;
	}
};

struct State
{
	lli cost;
	li k;
	State () : cost(LONG_LONG_MAX), k(0) {}
};

li p[M];
State d[1 << M];

void solve ()
{
	p[0] = 1;
	for (li i = 1; i < M; ++ i) p[i] = p[i - 1] * 2;

	vector <Friend> f;

	li n, monitors, c;
	scanf("%ld %ld %ld", &n, &monitors, &c);

	for (li i = 0; i < n; ++ i)
	{
		li x, k, m;
		scanf("%ld %ld %ld", &x, &k, &m);
		li mask = 0;
		for (li j = 0; j < m; ++ j)
		{
			li index;
			scanf("%ld", &index);
			mask |= p[index - 1];
		}
		f.push_back(Friend(x, k, mask));
	}

	lli ans = LONG_LONG_MAX;
	fill(d, d + p[monitors], State());
	d[0].cost = 0;
	for (li mask = 0; mask < p[monitors]; ++ mask)
	{
		if (d[mask].cost == LONG_LONG_MAX) continue;
		for (li i = 0; i < n; ++ i)
		{
			li nmask = mask | f[i].mask, nk = max(f[i].k, d[mask].k);
			lli ncost = d[mask].cost + (nmask != mask ? f[i].x : 0);
			if (d[nmask].cost == LONG_LONG_MAX || ncost + nk * 1LL * c <= d[nmask].cost)
			{
				d[nmask].cost = ncost;
				d[nmask].k = max(d[nmask].k, nk);
			}
		}
	}
	ans = d[p[monitors] - 1].cost + d[p[monitors] - 1].k * 1LL * c;

	printf("%I64d\n", ans == LONG_LONG_MAX ? -1 : ans);
}

void init ()
{
	freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
}

int main()
{
	//init();
	solve();
	return 0;
}


#include <cstdio>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <iterator>
#include <list>
#include <set>
#include <queue>
#include <numeric>
#include <cstdlib>
#include <ctime>
#include <climits>

using namespace std;

typedef long long lli;
typedef long li;

const lli INFLL = LONG_LONG_MAX;
const li INF = LONG_MAX;

void solve ()
{

}

void init ()
{
	freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
}

int main()
{
	init();
	solve();
	return 0;
}


#include <cstdio>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <iterator>
#include <list>
#include <set>
#include <queue>
#include <numeric>
#include <cstdlib>
#include <ctime>
#include <climits>

using namespace std;

typedef long long lli;
typedef long li;

template <class T>
T Minimize (T& v, T nv)
{
	if (nv < v) v = nv;
}

const lli INFLL = LONG_LONG_MAX;
const li INF = LONG_MAX, M = 21, N = 101;

struct Friend
{
	li x, k, mask;
	Friend () {}
	Friend (li x, li k, li mask) : x(x), k(k), mask(mask) {}
	bool operator < (const Friend &f) const
	{
		return k < f.k;
	}
};

li p[M], n, monitors;
li dv[1 << M], curdv;
li d[1 << M];
Friend f[N];
vector <Friend*> friends[M];

lli calc (li mask)
{
	if (dv[mask] == curdv) return d[mask];

	lli res = INFLL;
	li bit = __builtin_ctz(mask);
	vector <Friend*> &fr = friends[bit];
	for (li i = 0, sz = fr.size(); i < sz; ++ i)
	{
		if (fr[i]->k > monitors) break;
		Minimize(res, calc(mask & ~fr[i]->mask) + fr[i]->x);
	}

	dv[mask] = curdv;
	return d[mask] = res;
}

bool cmp (const Friend *a, const Friend *b)
{
	return *a < *b;
}

void solve ()
{
	p[0] = 1;
	for (li i = 1; i < M; ++ i) p[i] = p[i - 1] * 2;

	li tasks, c;
	scanf("%ld %ld %ld", &n, &tasks, &c);

	set <li> monitors;
	for (li i = 0; i < n; ++ i)
	{
		li x, k, m;
		scanf("%ld %ld %ld", &f[i].x, &f[i].k, &m);
		monitors.insert(f[i].k);
		for (li j = 0; j < m; ++ j)
		{
			li index;
			scanf("%ld", &index);
			f[i].mask |= p[index - 1];
			friends[index - 1].push_back(f + i);
		}
	}

	for (li i = 0; i < tasks; ++ i)
	{
		sort(friends[i].begin(), friends[i].end(), cmp);
	}

	d[0] = 0;
	lli res = INFLL;
	for (set<li>::iterator i = monitors.begin(); i != monitors.end(); ++ i)
	{
		curdv ++;
		dv[0] = curdv;
		::monitors = *i;
		Minimize(res, calc(p[tasks] - 1) + ::monitors * 1LL * c);
	}

	printf("%I64d\n", res == INFLL ? -1 : res);
}

void init ()
{
	freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
}

int main()
{
	//init();
	solve();
	return 0;
}


#include <cstdio>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <iterator>
#include <list>
#include <set>
#include <queue>
#include <numeric>
#include <cstdlib>
#include <ctime>
#include <climits>

using namespace std;

typedef long long lli;
typedef long li;

template <class T>
T Minimize (T& v, T nv)
{
	if (nv < v) v = nv;
}

const lli INFLL = LONG_LONG_MAX;
const li INF = LONG_MAX, M = 21, N = 101;

struct Friend
{
	li x, k, mask;
	Friend () {}
	Friend (li x, li k, li mask) : x(x), k(k), mask(mask) {}
	bool operator < (const Friend &f) const
	{
		return k < f.k;
	}
};

li p[M], n, monitors;
li dv[1 << M], curdv;
lli d[1 << M];
Friend f[N];
vector <Friend*> friends[M];

lli calc (li mask)
{
	if (dv[mask] == curdv) return d[mask];

	lli res = INFLL;
	li bit = __builtin_ctz(mask);
	vector <Friend*> &fr = friends[bit];
	for (li i = 0, sz = fr.size(); i < sz; ++ i)
	{
		if (fr[i]->k > monitors) break;
		Minimize(res, calc(mask & ~fr[i]->mask) + fr[i]->x);
	}

	return dv[mask] = curdv, d[mask] = res;
}

bool cmp (const Friend *a, const Friend *b)
{
	return *a < *b;
}

void solve ()
{
	p[0] = 1;
	for (li i = 1; i < M; ++ i) p[i] = p[i - 1] * 2;

	li tasks, c;
	scanf("%ld %ld %ld", &n, &tasks, &c);

	set <li> monitors;
	for (li i = 0; i < n; ++ i)
	{
		li x, k, m;
		scanf("%ld %ld %ld", &f[i].x, &f[i].k, &m);
		monitors.insert(f[i].k);
		for (li j = 0; j < m; ++ j)
		{
			li index;
			scanf("%ld", &index);
			f[i].mask |= p[index - 1];
			friends[index - 1].push_back(f + i);
		}
	}

	for (li i = 0; i < tasks; ++ i)
	{
		sort(friends[i].begin(), friends[i].end(), cmp);
	}

	d[0] = 0;
	lli ans = INFLL;
	for (set<li>::iterator i = monitors.begin(); i != monitors.end(); ++ i)
	{
		curdv ++;
		dv[0] = curdv;
		::monitors = *i;
		lli res = calc(p[tasks] - 1);
		if (res != INFLL)
		{
			Minimize(ans, res + ::monitors * 1LL * c);
		}
	}

	printf("%I64d\n", ans == INFLL ? -1 : ans);
}

void init ()
{
	freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
}

int main()
{
	//init();
	solve();
	return 0;
}


#include <cstdio>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <iterator>
#include <list>
#include <set>
#include <queue>
#include <numeric>
#include <cstdlib>
#include <ctime>
#include <climits>

using namespace std;

typedef long long lli;
typedef long li;

const lli INFLL = (lli)2e18;
const li INF = (li)2e9, M = 21;

struct Friend
{
	li x, k, mask;
	Friend (li x, li k, li mask) : x(x), k(k), mask(mask) {}
	bool operator < (const Friend &f) const
	{
		return k < f.k;
	}
	bool operator < (li x) const
	{
		return k < x;
	}
};

struct State
{
	lli cost;
	li k;
	State () : cost(LONG_LONG_MAX), k(0) {}
};

li p[M];
State d[1 << M];

void solve ()
{
	p[0] = 1;
	for (li i = 1; i < M; ++ i) p[i] = p[i - 1] * 2;

	vector <Friend> f;

	li n, monitors, c;
	scanf("%ld %ld %ld", &n, &monitors, &c);

	for (li i = 0; i < n; ++ i)
	{
		li x, k, m;
		scanf("%ld %ld %ld", &x, &k, &m);
		li mask = 0;
		for (li j = 0; j < m; ++ j)
		{
			li index;
			scanf("%ld", &index);
			mask |= p[index - 1];
		}
		f.push_back(Friend(x, k, mask));
	}

	lli ans = LONG_LONG_MAX;
	fill(d, d + p[monitors], State());
	d[0].cost = 0;
	for (li mask = 0; mask < p[monitors]; ++ mask)
	{
		if (d[mask].cost == LONG_LONG_MAX) continue;
		for (li i = 0; i < n; ++ i)
		{
			li nmask = mask | f[i].mask, nk = max(f[i].k, d[mask].k);
			lli ncost = d[mask].cost + (nmask != mask ? f[i].x : 0);
			if (d[nmask].cost == LONG_LONG_MAX || ncost + nk * 1LL * c <= d[nmask].cost)
			{
				d[nmask].cost = ncost;
				d[nmask].k = nk;
			}
		}
	}
	ans = d[p[monitors] - 1].cost + d[p[monitors] - 1].k * 1LL * c;

	printf("%I64d\n", ans == LONG_LONG_MAX ? -1 : ans);
}

void init ()
{
	freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
}

int main()
{
	//init();
	solve();
	return 0;
}


#include <cstdio>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <iterator>
#include <list>
#include <set>
#include <queue>
#include <numeric>
#include <cstdlib>
#include <ctime>
#include <climits>

using namespace std;

typedef long long lli;
typedef long li;

const lli INFLL = (lli)2e18;
const li INF = (li)2e9, M = 21;

struct Friend
{
	li x, k, mask;
	Friend (li x, li k, li mask) : x(x), k(k), mask(mask) {}
	bool operator < (const Friend &f) const
	{
		return k < f.k;
	}
	bool operator < (li x) const
	{
		return k < x;
	}
};

struct State
{
	lli cost;
	li k;
	State () : cost(LONG_LONG_MAX), k(0) {}
};

li p[M];
State d[1 << M];

void solve ()
{
	p[0] = 1;
	for (li i = 1; i < M; ++ i) p[i] = p[i - 1] * 2;

	vector <Friend> f;

	li n, tasks, c;
	scanf("%ld %ld %ld", &n, &tasks, &c);

	for (li i = 0; i < n; ++ i)
	{
		li x, k, m;
		scanf("%ld %ld %ld", &x, &k, &m);
		li mask = 0;
		for (li j = 0; j < m; ++ j)
		{
			li index;
			scanf("%ld", &index);
			mask |= p[index - 1];
		}
		f.push_back(Friend(x, k, mask));
	}

	lli ans = LONG_LONG_MAX;
	fill(d, d + p[tasks], State());
	d[0].cost = 0;
	for (li mask = 0; mask < p[tasks]; ++ mask)
	{
		if (d[mask].cost == LONG_LONG_MAX) continue;
		for (li i = 0; i < n; ++ i)
		{
			li nmask = mask | f[i].mask, nk = max(f[i].k, d[mask].k);
			lli ncost = d[mask].cost + (nmask != mask ? f[i].x : 0);
			if (d[nmask].cost == LONG_LONG_MAX || ncost + nk * 1LL * c <= d[nmask].cost + d[nmask].k * 1LL * c)
			{
				d[nmask].cost = ncost;
				d[nmask].k = nk;
			}
		}
	}
	ans = d[p[tasks] - 1].cost + d[p[tasks] - 1].k * 1LL * c;

	printf("%I64d\n", ans == LONG_LONG_MAX ? -1 : ans);
}

void init ()
{
	freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
}

int main()
{
	//init();
	solve();
	return 0;
}


#include <cstdio>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <iterator>
#include <list>
#include <set>
#include <queue>
#include <numeric>
#include <cstdlib>
#include <ctime>
#include <climits>

using namespace std;

typedef long long lli;
typedef long li;

template <class T>
T Minimize (T& v, T nv)
{
	if (nv < v) v = nv;
}

const lli INFLL = LONG_LONG_MAX;
const li INF = LONG_MAX, M = 21, N = 101;

struct Friend
{
	li x, k, mask;
	Friend () {}
	Friend (li x, li k, li mask) : x(x), k(k), mask(mask) {}
	bool operator < (const Friend &f) const
	{
		return k < f.k;
	}
};

li p[M], n, monitors;
li dv[1 << M], curdv;
lli d[1 << M];
Friend f[N];
vector <Friend*> friends[M];

lli calc (li mask)
{
	if (dv[mask] == curdv) return d[mask];

	lli res = INFLL;
	li bit = __builtin_ctz(mask);
	vector <Friend*> &fr = friends[bit];
	for (li i = 0, sz = fr.size(); i < sz; ++ i)
	{
		if (fr[i]->k > monitors) break;
		lli tmp = calc(mask & ~fr[i]->mask);
		if (tmp != INFLL) Minimize(res, tmp + fr[i]->x);
	}

	return dv[mask] = curdv, d[mask] = res;
}

bool cmp (const Friend *a, const Friend *b)
{
	return *a < *b;
}

void solve ()
{
	p[0] = 1;
	for (li i = 1; i < M; ++ i) p[i] = p[i - 1] * 2;

	li tasks, c;
	scanf("%ld %ld %ld", &n, &tasks, &c);

	set <li> monitors;
	for (li i = 0; i < n; ++ i)
	{
		li x, k, m;
		scanf("%ld %ld %ld", &f[i].x, &f[i].k, &m);
		monitors.insert(f[i].k);
		for (li j = 0; j < m; ++ j)
		{
			li index;
			scanf("%ld", &index);
			f[i].mask |= p[index - 1];
			friends[index - 1].push_back(f + i);
		}
	}

	for (li i = 0; i < tasks; ++ i)
	{
		sort(friends[i].begin(), friends[i].end(), cmp);
	}

	d[0] = 0;
	lli ans = INFLL;
	for (set<li>::iterator i = monitors.begin(); i != monitors.end(); ++ i)
	{
		curdv ++;
		dv[0] = curdv;
		::monitors = *i;
		lli res = calc(p[tasks] - 1);
		if (res != INFLL) Minimize(ans, res + ::monitors * 1LL * c);
	}

	printf("%I64d\n", ans == INFLL ? -1 : ans);
}

void init ()
{
	freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
}

int main()
{
	//init();
	solve();
	return 0;
}


#include <cstdio>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <iterator>
#include <list>
#include <set>
#include <queue>
#include <numeric>
#include <cstdlib>
#include <ctime>

using namespace std;

typedef long long lli;
typedef long li;

const lli INFLL = (lli)2e18;
const li INF = (li)2e9, M = 21;

struct Friend
{
	li x, k, mask;
	Friend (li x, li k, li mask) : x(x), k(k), mask(mask) {}
	bool operator < (const Friend &f) const
	{
		return k < f.k;
	}
	bool operator < (li x) const
	{
		return k < x;
	}
};

li p[M];
lli d[1 << M];

void solve ()
{
	p[0] = 1;
	for (li i = 1; i < M; ++ i) p[i] = p[i - 1] * 2;

	vector <Friend> f;

	li n, monitors, c;
	scanf("%ld %ld %ld", &n, &monitors, &c);

	for (li i = 0; i < n; ++ i)
	{
		li x, k, m;
		scanf("%ld %ld %ld", &x, &k, &m);
		li mask = 0;
		for (li j = 0; j < m; ++ j)
		{
			li index;
			scanf("%ld", &index);
			mask |= p[index - 1];
		}
		f.push_back(Friend(x, k, mask));
	}

	li ansMask = p[monitors] - 1;
	lli ans = INFLL;
	for (li l = 0, r = (li)1e9 + 1; l < r;)
	{
		li m = (l + r) / 2;
		li nn = upper_bound(f.begin(), f.end(), Friend(0, m, 0)) - f.begin();
		fill(d, d + p[monitors], INFLL);
		d[0] = 0;
		for (li mask = 0; mask < p[monitors]; ++ mask)
		{
			if (d[mask] == INFLL) continue;
			for (li i = 0; i < nn; ++ i)
			{
				li nmask = mask | f[i].mask;
				d[nmask] = min(d[nmask], d[mask] + (nmask != mask ? f[i].x : 0));
			}
		}
		lli nans = d[ansMask] + m * 1LL * c;
		if (nans <= ans)
		{
			ans = nans;
			r = m;
		}
		else
		{
			l = m + 1;
		}
	}

	printf("%I64d\n", ans == INFLL ? -1 : ans);
}

void init ()
{
	freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
}

int main()
{
	//init();
	solve();
	return 0;
}


#include <iostream>
#include <stdio.h>
#include <memory.h>
#include <stdlib.h>
using namespace std;
const int maxn = 105;
int n,p,b;
int x[maxn],k[maxn],m[maxn];
int a[maxn][maxn];
int vis[maxn],v[maxn];
int q[maxn];
int top=0;
long long ans=0,mm=0x3f3f3f3f3f3f3f3f;
void dfs(int s, int lay)
{
    int ii;
    for(ii=1;ii<=p;ii++) if(!vis[ii]) break;
    if(ii>p)
    {
        ans=ans+(long long)q[top]*b;
        if(ans<mm) mm=ans;
        ans-=q[top]*b;
        return;
    }
    if(lay>=n)
    {
        return;
    }
    for(int i=s;i<n;i++) if(!v[i])
    {
        v[i]=1;
        bool flag = false;
        if(k[i]>q[top]) {flag = true; q[++top]=k[i];}
        ans=ans+x[i];
        for(int j=0;j<m[i];j++) vis[a[i][j]]++;
        dfs(i+1,lay+1);
        if(flag) top--;
        ans=ans-x[i];
        for(int j=0;j<m[i];j++) vis[a[i][j]]--;
        v[i]=0;
    }
}
int main()
{
    scanf("%d%d%d",&n,&p,&b);
    for(int i=0;i<n;i++)
    {
        scanf("%d%d%d",&x[i],&k[i],&m[i]);
        for(int j=0;j<m[i];j++) scanf("%d",&a[i][j]);
    }
    dfs(0,0);
    if(mm==0x3f3f3f3f3f3f3f3f) printf("-1\n");
    else printf("%I64d\n",mm);
    return 0;
}


#include <iostream>
#include <stdio.h>
#include <memory.h>
#include <stdlib.h>
using namespace std;
const int maxn = 105;
int n,p,b;
int x[maxn],k[maxn],m[maxn];
int a[maxn][maxn];
int vis[maxn],v[maxn];
int ans=0,mm=0x3f3f3f3f;
void dfs(int lay)
{
    int ii;
    for(ii=1;ii<=p;ii++) if(!vis[ii]) break;
    if(ii>p)
    {
        if(ans<mm) mm=ans;
        return;
    }
    if(lay>=n)
    {
        return;
        //for(int i=1;i<=p;i++) if(!vis[i]) return;
        //if(ans<mm) mm=ans;
    }
    for(int i=0;i<n;i++) if(!v[i])
    {
        v[i]=1;
        ans+=x[i]+b*k[i];
        for(int j=0;j<m[i];j++) vis[a[i][j]]++;
        dfs(lay+1);
        ans-=x[i]+b*k[i];
        for(int j=0;j<m[i];j++) vis[a[i][j]]--;
        v[i]=0;
    }
}
int main()
{
    scanf("%d%d%d",&n,&p,&b);
    for(int i=0;i<n;i++)
    {
        scanf("%d%d%d",&x[i],&k[i],&m[i]);
        for(int j=0;j<m[i];j++) scanf("%d",&a[i][j]);
    }
    dfs(0);
    if(mm==0x3f3f3f3f) printf("-1\n");
    else printf("%d\n",mm);
    return 0;
}


#include <iostream>
#include <stdio.h>
#include <memory.h>
#include <stdlib.h>
using namespace std;
const int maxn = 105;
int n,p,b;
int x[maxn],k[maxn],m[maxn];
int a[maxn][maxn];
int vis[maxn],v[maxn];
int ans=0,mm=0x3f3f3f3f;
int maxk=0;
void dfs(int lay)
{
    int ii;
    for(ii=1;ii<=p;ii++) if(!vis[ii]) break;
    if(ii>p)
    {
        ans+=maxk*b;
        if(ans<mm) mm=ans;
        return;
    }
    if(lay>=n)
    {
        return;
        //for(int i=1;i<=p;i++) if(!vis[i]) return;
        //if(ans<mm) mm=ans;
    }
    for(int i=0;i<n;i++) if(!v[i])
    {
        v[i]=1;
        int t=maxk;
        if(k[i]>maxk) maxk=k[i];
        ans+=x[i];
        for(int j=0;j<m[i];j++) vis[a[i][j]]++;
        dfs(lay+1);
        if(k[i]>maxk) maxk=t;
        ans-=x[i];
        for(int j=0;j<m[i];j++) vis[a[i][j]]--;
        v[i]=0;
    }
}
int main()
{
    scanf("%d%d%d",&n,&p,&b);
    for(int i=0;i<n;i++)
    {
        scanf("%d%d%d",&x[i],&k[i],&m[i]);
        for(int j=0;j<m[i];j++) scanf("%d",&a[i][j]);
    }
    dfs(0);
    if(mm==0x3f3f3f3f) printf("-1\n");
    else printf("%d\n",mm);
    return 0;
}


#include <iostream>
#include <stdio.h>
#include <memory.h>
#include <stdlib.h>
using namespace std;
const int maxn = 105;
int n,p,b;
int x[maxn],k[maxn],m[maxn];
int a[maxn][maxn];
int vis[maxn],v[maxn];
int q[maxn];
int top=0;
long long ans=0,mm=0x3f3f3f3f3f3f3f3f;
void dfs(int lay)
{
    int ii;
    for(ii=1;ii<=p;ii++) if(!vis[ii]) break;
    if(ii>p)
    {
        ans=ans+(long long)q[top]*b;
        if(ans<mm) mm=ans;
        ans-=q[top]*b;
        return;
    }
    if(lay>=n)
    {
        return;
        //for(int i=1;i<=p;i++) if(!vis[i]) return;
        //if(ans<mm) mm=ans;
    }
    for(int i=0;i<n;i++) if(!v[i])
    {
        v[i]=1;
        if(k[i]>q[top]) q[++top]=k[i];
        ans=ans+x[i];
        for(int j=0;j<m[i];j++) vis[a[i][j]]++;
        dfs(lay+1);
        top--;
        ans=ans-x[i];
        for(int j=0;j<m[i];j++) vis[a[i][j]]--;
        v[i]=0;
    }
}
int main()
{
    scanf("%d%d%d",&n,&p,&b);
    for(int i=0;i<n;i++)
    {
        scanf("%d%d%d",&x[i],&k[i],&m[i]);
        for(int j=0;j<m[i];j++) scanf("%d",&a[i][j]);
    }
    dfs(0);
    if(mm==0x3f3f3f3f) printf("-1\n");
    else printf("%I64d\n",mm);
    return 0;
}


#include <iostream>
#include <stdio.h>
#include <memory.h>
#include <stdlib.h>
using namespace std;
const int maxn = 105;
const long long inf = 0x3f3f3f3f3f3f3f3f;
int n,m,b;
struct fr{
    int x,k,pn;
}a[maxn];
long long f[1<<20];
long long ans=inf;
int cmp(const void *a, const void *b)
{
    fr aa= *(fr *)a;
    fr bb= *(fr *)b;
    return aa.k-bb.k;
}
long long dp()
{
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<(1<<m);j++)
        {
            f[j|a[i].pn]=min(f[j|a[i].pn],a[i].x+f[j]);
        }
        if(a[i].k*b+f[(1<<m)-1]<ans) ans=a[i].k*b+f[(1<<m)-1];
    }
    if(ans==inf) return -1;
    return ans;
}
int main()
{
    scanf("%d%d%d",&n,&m,&b);
    for(int i=0;i<n;i++)
    {
        int x,y;
        scanf("%d%d%d",&a[i].x,&a[i].k,&x);
        for(int j=0;j<x;j++)
        {
            scanf("%d",&y);
            a[i].pn|=1<<(y-1);
        }
    }
    memset(f,0x3f,sizeof(f));
    f[0]=0;
    printf("%I64d\n",dp());
    return 0;
}


#include <iostream>
#include <stdio.h>
#include <memory.h>
#include <stdlib.h>
using namespace std;
const int maxn = 105;
int n,p,b;
int x[maxn],k[maxn],m[maxn],pn[maxn];
int vis,v[maxn];
int q[maxn];
int top=0;
long long ans=0,mm=0x3f3f3f3f3f3f3f3f;
void dfs(int s, int lay)
{
    if(vis==(1<<p)-1)
    {
        ans=ans+(long long)q[top]*b;
        if(ans<mm) mm=ans;
        ans-=q[top]*b;
        return;
    }
    if(lay>=n)
    {
        return;
    }
    for(int i=s;i<n;i++) if(!v[i])
    {
        v[i]=1;
        bool flag = false;
        if(k[i]>q[top]) {flag = true; q[++top]=k[i];}
        ans=ans+x[i];
        int pre=vis;
        vis|=pn[i];
        dfs(i+1,lay+1);
        if(flag) top--;
        ans=ans-x[i];
        vis=pre;
        v[i]=0;
    }
}
int main()
{
    scanf("%d%d%d",&n,&p,&b);
    for(int i=0;i<n;i++)
    {
        scanf("%d%d%d",&x[i],&k[i],&m[i]);
        for(int j=0;j<m[i];j++)
        {
            int x;
            scanf("%d",&x);
            pn[i]|=1<<(x-1);
        }
    }
    dfs(0,0);
    if(mm==0x3f3f3f3f3f3f3f3f) printf("-1\n");
    else printf("%I64d\n",mm);
    return 0;
}


#include <iostream>
#include <stdio.h>
#include <memory.h>
#include <stdlib.h>
using namespace std;
const int maxn = 105;
const long long inf = 0x3f3f3f3f3f3f3f3f;
int n,m;
long long b;
struct fr{
    int x,k,pn;
}a[maxn];
long long f[1<<20];
long long ans=inf;
int cmp(const void *a, const void *b)
{
    fr aa= *(fr *)a;
    fr bb= *(fr *)b;
    return aa.k-bb.k;
}
long long dp()
{
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<(1<<m);j++)
        {
            f[j|a[i].pn]=min(f[j|a[i].pn],a[i].x+f[j]);
        }
        if(a[i].k*b+f[(1<<m)-1]<ans) ans=a[i].k*b+f[(1<<m)-1];
    }
    if(ans==inf) return -1;
    return ans;
}
int main()
{
    scanf("%d%d%d",&n,&m,&b);
    for(int i=0;i<n;i++)
    {
        int x,y;
        scanf("%d%d%d",&a[i].x,&a[i].k,&x);
        for(int j=0;j<x;j++)
        {
            scanf("%d",&y);
            a[i].pn|=1<<(y-1);
        }
    }
    memset(f,0x3f,sizeof(f));
    f[0]=0;
    printf("%I64d\n",dp());
    return 0;
}


#include <iostream>
#include <stdio.h>
#include <memory.h>
#include <stdlib.h>
using namespace std;
const int maxn = 105;
int n,p,b;
int x[maxn],k[maxn],m[maxn];
int a[maxn][maxn];
int vis[maxn],v[maxn];
int q[maxn];
int top=0;
long long ans=0,mm=0x3f3f3f3f3f3f3f3f;
void dfs(int lay)
{
    int ii;
    for(ii=1;ii<=p;ii++) if(!vis[ii]) break;
    if(ii>p)
    {
        ans=ans+(long long)q[top]*b;
        if(ans<mm) mm=ans;
        ans-=q[top]*b;
        return;
    }
    if(lay>=n)
    {
        return;
        //for(int i=1;i<=p;i++) if(!vis[i]) return;
        //if(ans<mm) mm=ans;
    }
    for(int i=0;i<n;i++) if(!v[i])
    {
        v[i]=1;
        if(k[i]>q[top]) q[++top]=k[i];
        ans=ans+x[i];
        for(int j=0;j<m[i];j++) vis[a[i][j]]++;
        dfs(lay+1);
        top--;
        ans=ans-x[i];
        for(int j=0;j<m[i];j++) vis[a[i][j]]--;
        v[i]=0;
    }
}
int main()
{
    scanf("%d%d%d",&n,&p,&b);
    for(int i=0;i<n;i++)
    {
        scanf("%d%d%d",&x[i],&k[i],&m[i]);
        for(int j=0;j<m[i];j++) scanf("%d",&a[i][j]);
    }
    dfs(0);
    if(mm==0x3f3f3f3f3f3f3f3f) printf("-1\n");
    else printf("%I64d\n",mm);
    return 0;
}


#include <iostream>
#include <stdio.h>
#include <memory.h>
#include <stdlib.h>
using namespace std;
const int maxn = 105;
int n,p,b;
int x[maxn],k[maxn],m[maxn];
int a[maxn][maxn];
int vis[maxn],v[maxn];
int q[maxn];
int top=0;
long long ans=0,mm=0x3f3f3f3f3f3f3f3f;
void dfs(int lay)
{
    int ii;
    for(ii=1;ii<=p;ii++) if(!vis[ii]) break;
    if(ii>p)
    {
        ans=ans+(long long)q[top]*b;
        if(ans<mm) mm=ans;
        ans-=q[top]*b;
        return;
    }
    if(lay>=n)
    {
        return;
        //for(int i=1;i<=p;i++) if(!vis[i]) return;
        //if(ans<mm) mm=ans;
    }
    for(int i=0;i<n;i++) if(!v[i])
    {
        v[i]=1;
        bool flag = false;
        if(k[i]>q[top]) {flag = true; q[++top]=k[i];}
        ans=ans+x[i];
        for(int j=0;j<m[i];j++) vis[a[i][j]]++;
        dfs(lay+1);
        if(flag) top--;
        ans=ans-x[i];
        for(int j=0;j<m[i];j++) vis[a[i][j]]--;
        v[i]=0;
    }
}
int main()
{
    scanf("%d%d%d",&n,&p,&b);
    for(int i=0;i<n;i++)
    {
        scanf("%d%d%d",&x[i],&k[i],&m[i]);
        for(int j=0;j<m[i];j++) scanf("%d",&a[i][j]);
    }
    dfs(0);
    if(mm==0x3f3f3f3f3f3f3f3f) printf("-1\n");
    else printf("%I64d\n",mm);
    return 0;
}
/*
7 2 738042723
5 6 2
1 2
8 23 1
1
6 47 1
2
4 49 1
2
2 49 1
1
10 70 1
1
10 72 2
1 2
*/


#include <iostream>
#include <stdio.h>
#include <memory.h>
#include <stdlib.h>
using namespace std;
const int maxn = 105;
int n,p,b;
int x[maxn],k[maxn],m[maxn];
int a[maxn][maxn];
int vis[maxn],v[maxn];
int q[maxn];
int top=0;
int ans=0,mm=0x3f3f3f3f;
void dfs(int lay)
{
    int ii;
    for(ii=1;ii<=p;ii++) if(!vis[ii]) break;
    if(ii>p)
    {
        ans+=q[top]*b;
        if(ans<mm) mm=ans;
        ans-=q[top]*b;
        return;
    }
    if(lay>=n)
    {
        return;
        //for(int i=1;i<=p;i++) if(!vis[i]) return;
        //if(ans<mm) mm=ans;
    }
    for(int i=0;i<n;i++) if(!v[i])
    {
        v[i]=1;
        if(k[i]>q[top]) q[++top]=k[i];
        ans+=x[i];
        for(int j=0;j<m[i];j++) vis[a[i][j]]++;
        dfs(lay+1);
        top--;
        ans-=x[i];
        for(int j=0;j<m[i];j++) vis[a[i][j]]--;
        v[i]=0;
    }
}
int main()
{
    scanf("%d%d%d",&n,&p,&b);
    for(int i=0;i<n;i++)
    {
        scanf("%d%d%d",&x[i],&k[i],&m[i]);
        for(int j=0;j<m[i];j++) scanf("%d",&a[i][j]);
    }
    dfs(0);
    if(mm==0x3f3f3f3f) printf("-1\n");
    else printf("%d\n",mm);
    return 0;
}


//#define LOCAL

#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;

#define NAME "417d"

long long dp[1<<20];
int id[1<<20];

struct friends
{
  int x, k, mask;
  friends() {}
  friends( int a, int b, int c ): x(a), k(b), mask(c) {}
  bool operator <( const friends &arg ) const
  {
    return k < arg.k;
  }
};

int main()
{
  #ifdef LOCAL
  freopen(NAME".in", "rt", stdin);
  freopen(NAME".out", "wt", stdout);
  #endif

  memset( id, -1, sizeof(id) );
  memset( dp, 63, sizeof(dp) );
  long long inf = dp[0];
  dp[0] = 0;

  int n, m, b;
  scanf("%d%d%d", &n, &m, &b);
  friends mf[n];
  for( int i = 0; i < n; ++i )
  {
    int x, k, p;
    int mask = 0;
    scanf("%d%d%d", &x, &k, &p);
    for( int j = 0; j < p; ++j )
    {
      int cp;
      scanf("%d", &cp);
      mask |= 1<<(cp - 1);
    }
    mf[i] = friends( x, k, mask );
  }

  sort( mf, mf + n );

  for( int i = 0; i < n; ++i )
    for( int j = 0; j < 1<<m; ++j )
    {
      int tm = j & (~mf[i].mask);
      if( id[tm] == -1 && tm != 0 ) continue;
      long long cost = mf[i].x + (long long)mf[i].k * b;
      if( id[tm] != -1 ) cost -= (long long)mf[id[tm]].k * b;
      if( dp[j] > dp[tm] + cost )
      {
	id[j] = i;
	dp[j] = dp[tm] + cost;
      }
    }

  if( dp[(1<<m) - 1] < inf )
    printf("%I64d", dp[(1<<m) - 1]);
  else printf("-1");

  #ifdef LOCAL
  fclose(stdin);
  fclose(stdout);
  #endif

  return 0;
}


//#define LOCAL

#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;

#define NAME "417d"

long long dp[1<<20];
int id[1<<20];

struct friends
{
  int x, k, mask;
  friends() {}
  friends( int a, int b, int c ): x(a), k(b), mask(c) {}
  bool operator <( const friends &arg ) const
  {
    return k < arg.k || ( k == arg.k && x < arg.x );
  }
};

int main()
{
  #ifdef LOCAL
  freopen(NAME".in", "rt", stdin);
  freopen(NAME".out", "wt", stdout);
  #endif

  memset( id, -1, sizeof(id) );
  memset( dp, 63, sizeof(dp) );
  long long inf = dp[0];
  dp[0] = 0;

  int n, m, b;
  scanf("%d%d%d", &n, &m, &b);
  friends mf[n];
  for( int i = 0; i < n; ++i )
  {
    int x, k, p;
    int mask = 0;
    scanf("%d%d%d", &x, &k, &p);
    for( int j = 0; j < p; ++j )
    {
      int cp;
      scanf("%d", &cp);
      mask |= 1<<(cp - 1);
    }
    mf[i] = friends( x, k, mask );
  }

  sort( mf, mf + n );

  for( int i = 0; i < n; ++i )
    for( int j = 0; j < 1<<m; ++j )
    {
      int tm = j & (~mf[i].mask);
      if( id[tm] == -1 && tm != 0 ) continue;
      long long cost = mf[i].x + (long long)mf[i].k * b;
      if( id[tm] != -1 ) cost -= (long long)mf[id[tm]].k * b;
      if( dp[j] > dp[tm] + cost )
      {
	id[j] = i;
	dp[j] = dp[tm] + cost;
      }
    }

  if( dp[(1<<m) - 1] < inf )
    printf("%I64d", dp[(1<<m) - 1]);
  else printf("-1");

  #ifdef LOCAL
  fclose(stdin);
  fclose(stdout);
  #endif

  return 0;
}


//#define LOCAL

#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;

#define NAME "417d"

long long dp[1<<20];
int id[1<<20];

struct friends
{
  int x, k, mask;
  friends() {}
  friends( int a, int b, int c ): x(a), k(b), mask(c) {}
  bool operator <( const friends &arg ) const
  {
    return k < arg.k || ( k == arg.k && x < arg.x );
  }
};

int main()
{
  #ifdef LOCAL
  freopen(NAME".in", "rt", stdin);
  freopen(NAME".out", "wt", stdout);
  #endif

  memset( id, -1, sizeof(id) );
  memset( dp, 63, sizeof(dp) );
  long long inf = dp[0];
  dp[0] = 0;

  int n, m, b;
  scanf("%d%d%d", &n, &m, &b);
  friends mf[n];
  for( int i = 0; i < n; ++i )
  {
    int x, k, p;
    int mask = 0;
    scanf("%d%d%d", &x, &k, &p);
    for( int j = 0; j < p; ++j )
    {
      int cp;
      scanf("%d", &cp);
      mask |= 1<<(cp - 1);
    }
    mf[i] = friends( x, k, mask );
  }

  sort( mf, mf + n );

  for( int i = 0; i < n; ++i )
  {
    long long cost = (long long)mf[i].x + (long long)mf[i].k * (long long)b;
    for( int j = 0; j < 1<<m; ++j )
    {
      int tm = j & (~mf[i].mask);
      if( id[tm] == -1 && tm != 0 ) continue;
      if( id[tm] != -1 ) cost -= (long long)mf[id[tm]].k * (long long)b;
      if( dp[j] > dp[tm] + cost )
      {
	id[j] = i;
	dp[j] = dp[tm] + cost;
      }
    }
  }

  if( dp[(1<<m) - 1] < inf )
    //printf("%lld", dp[(1<<m) - 1]);
    printf("%I64d", dp[(1<<m) - 1]);
  else printf("-1");

  #ifdef LOCAL
  fclose(stdin);
  fclose(stdout);
  #endif

  return 0;
}


//#define LOCAL

#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;

#define NAME "417d"

long long dp[1<<20];

struct friends
{
  int x, k, mask;
  friends() {}
  friends( int a, int b, int c ): x(a), k(b), mask(c) {}
  bool operator <( const friends &arg ) const
  {
    return k < arg.k || ( k == arg.k && x < arg.x );
  }
};

int main()
{
  #ifdef LOCAL
  freopen(NAME".in", "rt", stdin);
  freopen(NAME".out", "wt", stdout);
  #endif

  memset( dp, 63, sizeof(dp) );
  long long inf = dp[0];
  dp[0] = 0;

  int n, m, b;
  scanf("%d%d%d", &n, &m, &b);
  friends mf[n];
  for( int i = 0; i < n; ++i )
  {
    int x, k, p;
    int mask = 0;
    scanf("%d%d%d", &x, &k, &p);
    for( int j = 0; j < p; ++j )
    {
      int cp;
      scanf("%d", &cp);
      mask |= 1<<(cp - 1);
    }
    mf[i] = friends( x, k, mask );
  }

  sort( mf, mf + n );

  long long ret = inf;

  for( int i = 0; i < n; ++i )
  {
    long long cost = mf[i].x;
    for( int j = 0; j < 1<<m; ++j )
    {
      int tm = j & (~mf[i].mask);
      if( dp[tm] >= inf ) continue;
      if( dp[j] > dp[tm] + cost ) dp[j] = dp[tm] + cost;
      if( dp[(1<<m) - 1] < inf )
      {
	if( ret > dp[(1<<m) - 1] + (long long)mf[i].k * b )
	  ret = dp[(1<<m) - 1] + (long long)mf[i].k * b;
      }
    }
  }

  if( ret < inf )
    //printf("%lld", ret);
    printf("%I64d", ret);
  else printf("-1");

  #ifdef LOCAL
  fclose(stdin);
  fclose(stdout);
  #endif

  return 0;
}


//#define LOCAL

#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;

#define NAME "417d"

long long dp[1<<20];
int id[1<<20];

struct friends
{
  int x, k, mask;
  friends() {}
  friends( int a, int b, int c ): x(a), k(b), mask(c) {}
  bool operator <( const friends &arg ) const
  {
    return k < arg.k || ( k == arg.k && x < arg.x );
  }
};

int main()
{
  #ifdef LOCAL
  freopen(NAME".in", "rt", stdin);
  freopen(NAME".out", "wt", stdout);
  #endif

  memset( id, -1, sizeof(id) );
  memset( dp, 63, sizeof(dp) );
  long long inf = dp[0];
  dp[0] = 0;

  int n, m, b;
  scanf("%d%d%d", &n, &m, &b);
  friends mf[n];
  for( int i = 0; i < n; ++i )
  {
    int x, k, p;
    int mask = 0;
    scanf("%d%d%d", &x, &k, &p);
    for( int j = 0; j < p; ++j )
    {
      int cp;
      scanf("%d", &cp);
      mask |= 1<<(cp - 1);
    }
    mf[i] = friends( x, k, mask );
  }

  sort( mf, mf + n );

  for( int i = 0; i < n; ++i )
  {
    long long cost = (long long)mf[i].x + (long long)mf[i].k * (long long)b;
    for( int j = 0; j < 1<<m; ++j )
    {
      int tm = j & (~mf[i].mask);
      if( id[tm] == -1 && tm != 0 ) continue;
      long long tc = cost;
      if( id[tm] != -1 ) tc -= (long long)mf[id[tm]].k * (long long)b;
      if( dp[j] > dp[tm] + tc )
      {
	id[j] = i;
	dp[j] = dp[tm] + tc;
      }
    }
  }

  if( dp[(1<<m) - 1] < inf )
    //printf("%lld", dp[(1<<m) - 1]);
    printf("%I64d", dp[(1<<m) - 1]);
  else printf("-1");

  #ifdef LOCAL
  fclose(stdin);
  fclose(stdout);
  #endif

  return 0;
}


//#define LOCAL

#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;

#define NAME "417d"

long long dp[1<<20];

struct friends
{
  int x, k, mask;
  friends() {}
  friends( int a, int b, int c ): x(a), k(b), mask(c) {}
  bool operator <( const friends &arg ) const
  {
    return k < arg.k || ( k == arg.k && x < arg.x );
  }
};

int main()
{
  #ifdef LOCAL
  freopen(NAME".in", "rt", stdin);
  freopen(NAME".out", "wt", stdout);
  #endif

  memset( dp, 63, sizeof(dp) );
  long long inf = dp[0];
  dp[0] = 0;

  int n, m, b;
  scanf("%d%d%d", &n, &m, &b);
  friends mf[n];
  for( int i = 0; i < n; ++i )
  {
    int x, k, p;
    int mask = 0;
    scanf("%d%d%d", &x, &k, &p);
    for( int j = 0; j < p; ++j )
    {
      int cp;
      scanf("%d", &cp);
      mask |= 1<<(cp - 1);
    }
    mf[i] = friends( x, k, mask );
  }

  sort( mf, mf + n );

  long long ret = inf;

  for( int i = 0; i < n; ++i )
  {
    long long cost = mf[i].x;
    for( int j = 0; j < 1<<m; ++j )
    {
      int tm = j & (~mf[i].mask);
      if( dp[tm] >= inf ) continue;
      if( dp[j] > dp[tm] + cost ) dp[j] = dp[tm] + cost;
      if( dp[(1<<m) - 1] < inf )
      {
	if( ret > dp[(1<<m) - 1] + mf[i].k * b )
	  ret = dp[(1<<m) - 1] + mf[i].k * b;
      }
    }
  }

  if( ret < inf )
    //printf("%lld", ret);
    printf("%I64d", ret);
  else printf("-1");

  #ifdef LOCAL
  fclose(stdin);
  fclose(stdout);
  #endif

  return 0;
}


#include <iostream>
#include <cmath>
#include <cstdio>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
using namespace std;

const long long inf = 1 << 60;
int n, m, b, c;

struct poc {
	long x, k, z;
};

vector<poc> a;

long long d[1 << 21];

bool cmp(poc x, poc y) {
	if (x.k < y.k) return true; else return false;
}

int main() {
  // freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);

	cin >> n >> m >> b;

	for (int i = 1; i <= n; i++) {
		poc lol;
		int kol;
		cin >> lol.x >> lol.k >> kol;
		lol.z = 0;
		for (int j = 1; j <= kol; j++) {
			cin >> c;
			c--;
			lol.z |= 1 << c;
		}
		a.push_back(lol);
	}
	sort(a.begin(), a.end(), cmp);
	for (int i = 0; i <= 1 << m; i++) d[i] = inf;

	long long ans = inf;
	d[0] = 0;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < 1 << m; j++) if (d[j] < inf) {
			int jj = j | a[i].z;
			d[jj] = min(d[jj], d[j] + a[i].x);
		}
		ans = min(ans, d[(1 << m) - 1] + b * a[i].k);
	}

	if (ans == inf) cout << -1; else cout << ans;
}


#include <iostream>
#include <cmath>
#include <cstdio>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
using namespace std;

const long long inf = 1000 * 1000 * 1000;
int n, m, b, c;

struct poc {
	long x, k, z;
};

vector<poc> a;

long long d[1 << 21];

bool cmp(poc x, poc y) {
	if (x.k < y.k) return true; else return false;
}

int main() {
  // freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);

	cin >> n >> m >> b;

	for (int i = 1; i <= n; i++) {
		poc lol;
		int kol;
		cin >> lol.x >> lol.k >> kol;
		lol.z = 0;
		for (int j = 1; j <= kol; j++) {
			cin >> c;
			c--;
			lol.z |= 1 << c;
		}
		a.push_back(lol);
	}
	sort(a.begin(), a.end(), cmp);
	for (int i = 0; i <= 1 << m; i++) d[i] = inf;

	long long ans = inf;
	d[0] = 0;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < 1 << m; j++) if (d[j] < inf) {
			int jj = j | a[i].z;
			d[jj] = min(d[jj], d[j] + a[i].x);
		}
		ans = min(ans, d[(1 << m) - 1] + b * a[i].k);
	}

	if (ans == inf) cout << -1; else cout << ans;
}


#include <iostream>
#include <cmath>
#include <cstdio>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
using namespace std;

const long long inf = 1000000000000000000;
long long n, m, b, c;

struct poc {
	long long x, k, z;
};

vector<poc> a;

long long d[1 << 21];

bool cmp(poc x, poc y) {
	if (x.k < y.k) return true; else return false;
}

int main() {
//   freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);

	cin >> n >> m >> b;

	for (int i = 1; i <= n; i++) {
		poc lol;
		int kol;
		cin >> lol.x >> lol.k >> kol;
		lol.z = 0;
		for (int j = 1; j <= kol; j++) {
			cin >> c;
			c--;
			lol.z |= 1 << c;
		}
		a.push_back(lol);
	}
	sort(a.begin(), a.end(), cmp);
	for (int i = 0; i <= 1 << m; i++) d[i] = inf;

	long long ans = inf;
	d[0] = 0;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < 1 << m; j++) if (d[j] < inf) {
			int jj = j | a[i].z;
			d[jj] = min(d[jj], d[j] + a[i].x);
		}
		ans = min(ans, d[(1 << m) - 1] + b * a[i].k);
	}

	if (ans == inf) cout << -1; else cout << ans;
}


#include <iostream>
#include <cmath>
#include <cstdio>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
using namespace std;

const long long inf = 1000000000000000000;
int n, m, b, c;

struct poc {
	long x, k, z;
};

vector<poc> a;

long long d[1 << 21];

bool cmp(poc x, poc y) {
	if (x.k < y.k) return true; else return false;
}

int main() {
//   freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);

	cin >> n >> m >> b;

	for (int i = 1; i <= n; i++) {
		poc lol;
		int kol;
		cin >> lol.x >> lol.k >> kol;
		lol.z = 0;
		for (int j = 1; j <= kol; j++) {
			cin >> c;
			c--;
			lol.z |= 1 << c;
		}
		a.push_back(lol);
	}
	sort(a.begin(), a.end(), cmp);
	for (int i = 0; i <= 1 << m; i++) d[i] = inf;

	long long ans = inf;
	d[0] = 0;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < 1 << m; j++) if (d[j] < inf) {
			int jj = j | a[i].z;
			d[jj] = min(d[jj], d[j] + a[i].x);
		}
		ans = min(ans, d[(1 << m) - 1] + b * a[i].k);
	}

	if (ans == inf) cout << -1; else cout << ans;
}


#include <iostream>
#include <cmath>
#include <cstdio>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
using namespace std;

const long long inf = 1 << 31;
int n, m, b, c;

struct poc {
	long x, k, z;
};

vector<poc> a;

long long d[1 << 21];

bool cmp(poc x, poc y) {
	if (x.k < y.k) return true; else return false;
}

int main() {
  // freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);

	cin >> n >> m >> b;

	for (int i = 1; i <= n; i++) {
		poc lol;
		int kol;
		cin >> lol.x >> lol.k >> kol;
		lol.z = 0;
		for (int j = 1; j <= kol; j++) {
			cin >> c;
			c--;
			lol.z |= 1 << c;
		}
		a.push_back(lol);
	}
	sort(a.begin(), a.end(), cmp);
	for (int i = 0; i <= 1 << m; i++) d[i] = inf;

	long long ans = inf;
	d[0] = 0;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < 1 << m; j++) if (d[j] < inf) {
			int jj = j | a[i].z;
			d[jj] = min(d[jj], d[j] + a[i].x);
		}
		ans = min(ans, d[(1 << m) - 1] + b * a[i].k);
	}

	if (ans == inf) cout << -1; else cout << ans;
}


#include <iostream>
#include <cmath>
#include <cstdio>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
using namespace std;

const long long inf = ((long long)1 << 62);
long long n, m, b, c;

struct poc {
	long long x, k, z;
};

vector<poc> a;

long long d[1 << 21];

bool cmp(poc x, poc y) {
	if (x.k < y.k) return true; else return false;
}

int main() {
//   freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);

	cin >> n >> m >> b;

	for (int i = 1; i <= n; i++) {
		poc lol;
		int kol;
		cin >> lol.x >> lol.k >> kol;
		lol.z = 0;
		for (int j = 1; j <= kol; j++) {
			cin >> c;
			c--;
			lol.z |= 1 << c;
		}
		a.push_back(lol);
	}
	sort(a.begin(), a.end(), cmp);
	for (int i = 0; i <= 1 << m; i++) d[i] = inf;

	long long ans = inf;
	d[0] = 0;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < 1 << m; j++) if (d[j] < inf) {
			int jj = j | a[i].z;
			d[jj] = min(d[jj], d[j] + a[i].x);
		}
		ans = min(ans, d[(1 << m) - 1] + b * a[i].k);
	}

	if (ans == inf) cout << -1; else cout << ans;
}


#include<algorithm>
#include<bitset>
#include<iostream>
#include<set>
#include<vector>

#define ll unsigned long long int
#define MAX_STATE  (1<<20)+1

using namespace std;

class Data {
	public:
		Data()
		{
			int cost = 0;
			int monitors = 0;
			int problems = 0;
			int state = 0;
		}
		int cost;
		int monitors;
		int problems;
		int state;
};

ll friends,problems,monitor_cost,p_friends;
int final_state,current_state;
vector<Data> data;
vector<Data> l_data;
ll MAX_COST = 1e19;
ll dp[MAX_STATE];

bool mycmp(Data a, Data b){
	if(a.state == b.state)
		return a.cost < b.cost;
	return a.state < b.state;
}

ll solve(int state,int total_monitors){
	//		bitset<20> f(state);
	//		cout<<"st"<<f<<endl;
	if(state == 0){
		//		cout<<"-------"<<f<<endl;
		return 0;
	}
	if(dp[state]!=MAX_COST){
		//		cout<<"&&&&&&&&&"<<f<<endl;
		return dp[state];
	}

	ll ans = MAX_COST;
	//	cout<<"----------------------S------------------"<<endl;
	for(int i=0;i<p_friends;i++){

		//		cout<<"i= "<<i<<" "<<f<<endl;
		if((l_data[i].monitors <= total_monitors) && ((state & l_data[i].state) != 0)) {
			ans = min(ans, (solve((state ^ (state & l_data[i].state)), total_monitors) + l_data[i].cost));
		}
		//		cout<<"i= "<<i<<"ans= "<<ans<<" "<<f<<endl;
	}
	//	cout<<"----------------------E------------------"<<endl;
	dp[state] = ans;
	return dp[state];
}

int main() {
	cin>>friends>>problems>>monitor_cost;
	final_state = (1<<problems)-1;
	current_state = 0;
	set<int> monitors_required;
	set<int> states_required;
	for(int i=0;i<friends;i++){
		Data d;
		cin>>d.cost>>d.monitors>>d.problems;
		d.state = 0;
		for(int j=0;j<d.problems;j++){
			int p;
			cin>>p;
			current_state |= (1<<(p-1));
			d.state |= (1<<(p-1));
		}
		data.push_back(d);
		monitors_required.insert(d.monitors);
		//cout<<"i= "<<i<<"state= "<<data[i].state<<" "<<d.state<<" "<<endl;
	}
	if(current_state == final_state){
		ll min_ans = MAX_COST;
		sort(data.begin(),data.end(),mycmp);
		/*
		for(int i=0;i<friends;i++){
			cout<<data[i].state<<" "<<data[i].cost<<" "<<data[i].monitors<<" "<<data[i].problems<<endl;
		}
		*/

		for(set<int>::iterator it=monitors_required.begin();it!=monitors_required.end();it++){
			ll monitors = *it;
			for(int j=0;j<(1<<problems);j++){
				dp[j]=MAX_COST;
			}
			current_state = 0;
			p_friends = 0;
			states_required.clear();
			l_data.clear();
			for(int i=0;i<friends;i++){
				pair<set<int>::iterator,bool> it2;
				if(data[i].monitors <= monitors) {
				 it2 = states_required.insert(data[i].state);
				 if(it2.second){
					 l_data.push_back(data[i]);
					 current_state |= data[i].state;
					 p_friends++;
				 }
				}
			}
			//			cout<<endl;
			//			cout<<endl;
			if(current_state == final_state) {
				ll ans = solve(final_state, monitors);
				//cout<<ans<<endl;
				if(ans != MAX_COST) {
					//cout<<"------------------------"<<endl;
					min_ans = min(min_ans, (ans + (monitor_cost * monitors)));
					//cout<<"------------------------"<<endl;
				}
			}
			//			cout<<endl;
			//			cout<<endl;
		}
		cout<<min_ans<<endl;
	}else{
		cout<<"-1"<<endl;
	}
	return 0;
}


#include<algorithm>
#include<bitset>
#include<iostream>
#include<set>
#include<vector>

#define ll unsigned long long int
#define MAX_STATE  (1<<20)+1

using namespace std;

class Data {
	public:
		Data()
		{
			int cost = 0;
			int monitors = 0;
			int problems = 0;
			int state = 0;
		}
		int cost;
		int monitors;
		int problems;
		int state;
};

ll friends,problems,monitor_cost,p_friends;
int final_state,current_state;
vector<Data> data;
ll MAX_COST = 1e19;
ll dp[MAX_STATE][101];

bool mycmp(Data a, Data b){
	return a.monitors < b.monitors;
}

ll solve(int state,int f){
	if(state == 0){
		return data[f-1].monitors*monitor_cost;
	}

	if(friends == f)
		return MAX_COST;

	if(dp[state][f]!=MAX_COST){
//		cout<<"state= "<<state<<" f= "<<f<<endl;
		return dp[state][f];
	}

	dp[state][f] = min(dp[state][f], (solve(state ^ (state & data[f].state), f + 1) + data[f].cost));
//	cout<<(solve(state ^ (state & data[f].state), f + 1))<<endl;
//	cout<<ans<<endl;
	dp[state][f] = min(dp[state][f], (solve(state , f + 1)));
//	cout<<ans<<endl;
	return dp[state][f];
}

int main() {
	cin>>friends>>problems>>monitor_cost;
	final_state = (1<<problems)-1;
	current_state = 0;
	set<int> monitors_required;
	set<int> states_required;
	for(int i=0;i<friends;i++){
		Data d;
		cin>>d.cost>>d.monitors>>d.problems;
		d.state = 0;
		for(int j=0;j<d.problems;j++){
			int p;
			cin>>p;
			current_state |= (1<<(p-1));
			d.state |= (1<<(p-1));
		}
		data.push_back(d);
	}
	if(current_state == final_state){
		sort(data.begin(),data.end(),mycmp);
		for(int i=0;i<(1<<problems);i++){
			for(int j=0;j<friends;j++){
				dp[i][j]=MAX_COST;
			}
		}
		ll ans = solve(final_state,0);
		cout<<ans<<endl;
	}else{
		cout<<"-1"<<endl;
	}
	return 0;
}


#include<iostream>
#include<bitset>

#define ll unsigned long long int
#define MAX_STATE  (1<<20)+1

using namespace std;

class Data {
	public:
		Data()
		{
			int cost = 0;
			int monitors = 0;
			int problems = 0;
			int state = 0;
		}
		int cost;
		int monitors;
		int problems;
		int state;
};

int friends,problems,monitor_cost;
int final_state,current_state;
Data data[101];
ll MAX_COST = 1e12;
ll dp[MAX_STATE] = {-1};

ll solve(int state,int total_monitors){
//		bitset<20> f(state);
//		cout<<"st"<<f<<endl;
	if(state == final_state){
		return 0;
	}
	ll ans = MAX_COST;
	ll cost;
	for(int i=0;i<friends;i++){
		if((data[i].monitors <= total_monitors) && ((state & data[i].state) != data[i].state)) {
			ans = min(MAX_COST, (solve(state|data[i].state, total_monitors) + data[i].cost));
		}
	}
//		cout<<ans<<" "<<f<<endl;
	return ans;
}

int main() {
	cin>>friends>>problems>>monitor_cost;
	final_state = (1<<problems)-1;
	current_state = 0;
	for(int i=0;i<friends;i++){
		cin>>data[i].cost>>data[i].monitors>>data[i].problems;
		for(int j=0;j<data[i].problems;j++){
			int p;
			cin>>p;
			current_state |= (1<<(p-1));
			data[i].state |= (1<<(p-1));
		}
//		cout<<"i= "<<i<<"state= "<<data[i].state<<endl;
	}
	ll min_ans = 1e19;
	if(current_state == final_state){
		for(int i=0;i<friends;i++){
			min_ans = min(min_ans, (solve(0, data[i].monitors) + (monitor_cost * data[i].monitors)));
			//cout<<(solve(0, data[i].monitors) + (monitor_cost * data[i].monitors))<<endl;
		}
		cout<<min_ans<<endl;
	}else{
		cout<<"-1"<<endl;
	}
	return 0;
}


#include<iostream>
#include<bitset>

#define ll unsigned long long int
#define MAX_STATE  (1<<20)+1

using namespace std;

class Data {
	public:
		Data()
		{
			int cost = 0;
			int monitors = 0;
			int problems = 0;
			int state = 0;
		}
		int cost;
		int monitors;
		int problems;
		int state;
};

ll friends,problems,monitor_cost;
int final_state,current_state;
Data data[101];
ll MAX_COST = 1e19;
ll dp[MAX_STATE];

ll solve(int state,int total_monitors){
//		bitset<20> f(state);
//		cout<<"st"<<f<<endl;
	if(state == 0){
//		cout<<"-------"<<f<<endl;
		return 0;
	}
	if(dp[state]!=MAX_COST){
//		cout<<"&&&&&&&&&"<<f<<endl;
		return dp[state];
	}

	ll ans = MAX_COST;
//	cout<<"----------------------S------------------"<<endl;
	for(int i=0;i<friends;i++){

//		cout<<"i= "<<i<<" "<<f<<endl;
		if((data[i].monitors <= total_monitors) && ((state & data[i].state) != 0)) {
			ans = min(ans, (solve((state^(state&data[i].state)), total_monitors) + data[i].cost));
		}
//		cout<<"i= "<<i<<"ans= "<<ans<<" "<<f<<endl;
	}
//	cout<<"----------------------E------------------"<<endl;
	dp[state] = ans;
	return dp[state];
}

int main() {
	cin>>friends>>problems>>monitor_cost;
	final_state = (1<<problems)-1;
	current_state = 0;
	for(int i=0;i<friends;i++){
		cin>>data[i].cost>>data[i].monitors>>data[i].problems;
		for(int j=0;j<data[i].problems;j++){
			int p;
			cin>>p;
			current_state |= (1<<(p-1));
			data[i].state |= (1<<(p-1));
		}
//		cout<<"i= "<<i<<"state= "<<data[i].state<<endl;
	}
	ll min_ans = MAX_COST;
	if(current_state == final_state){
		for(int i=0;i<friends;i++){
			for(int j=0;j<(1<<problems);j++){
				dp[j]=MAX_COST;
			}
//			cout<<endl;
//			cout<<endl;
			ll ans = solve(final_state, data[i].monitors);
//			cout<<ans<<endl;
			if(ans != MAX_COST) {
//				cout<<"------------------------"<<endl;
				min_ans = min(min_ans, (solve(final_state, data[i].monitors) + (monitor_cost * data[i].monitors)));
//				cout<<"i= "<<i<<"monitors= "<<data[i].monitors<<"ans= "<<(ans + (monitor_cost * data[i].monitors))<<endl;
//				cout<<"------------------------"<<endl;
			}
//			cout<<endl;
//			cout<<endl;
		}
		cout<<min_ans<<endl;
	}else{
		cout<<"-1"<<endl;
	}
	return 0;
}


#include<algorithm>
#include<bitset>
#include<iostream>
#include<set>
#include<vector>

#define ll unsigned long long int
#define MAX_STATE  (1<<20)+1

using namespace std;

class Data {
	public:
		Data()
		{
			int cost = 0;
			int monitors = 0;
			int problems = 0;
			int state = 0;
		}
		int cost;
		int monitors;
		int problems;
		int state;
};

ll friends,problems,monitor_cost,p_friends;
int final_state,current_state;
vector<Data> data;
vector<Data> l_data;
ll MAX_COST = 1e19;
ll dp[MAX_STATE];

bool mycmp(Data a, Data b){
	if(a.state == b.state)
		return a.cost < b.cost;
	return a.state < b.state;
}

ll solve(int state){
	//		bitset<20> f(state);
	//		cout<<"st"<<f<<endl;
	if(state == 0){
		//		cout<<"-------"<<f<<endl;
		return 0;
	}
	if(dp[state]!=MAX_COST){
		//		cout<<"&&&&&&&&&"<<f<<endl;
		return dp[state];
	}

	ll ans = MAX_COST;
	//	cout<<"----------------------S------------------"<<endl;
	for(int i=0;i<p_friends;i++){

		//		cout<<"i= "<<i<<" "<<f<<endl;
		if ((state & l_data[i].state) != 0) {
			ans = min(ans, (solve(state ^ (state & l_data[i].state)) + l_data[i].cost));
		}
		//		cout<<"i= "<<i<<"ans= "<<ans<<" "<<f<<endl;
	}
	//	cout<<"----------------------E------------------"<<endl;
	dp[state] = ans;
	return dp[state];
}

int main() {
	cin>>friends>>problems>>monitor_cost;
	final_state = (1<<problems)-1;
	current_state = 0;
	set<int> monitors_required;
	set<int> states_required1;
	set<int> states_required2;
	for(int i=0;i<friends;i++){
		Data d;
		cin>>d.cost>>d.monitors>>d.problems;
		d.state = 0;
		for(int j=0;j<d.problems;j++){
			int p;
			cin>>p;
			current_state |= (1<<(p-1));
			d.state |= (1<<(p-1));
		}
		data.push_back(d);
		monitors_required.insert(d.monitors);
		//cout<<"i= "<<i<<"state= "<<data[i].state<<" "<<d.state<<" "<<endl;
	}
	if(current_state == final_state){
		ll min_ans = MAX_COST;
		sort(data.begin(),data.end(),mycmp);
		/*
		for(int i=0;i<friends;i++){
			cout<<data[i].state<<" "<<data[i].cost<<" "<<data[i].monitors<<" "<<data[i].problems<<endl;
		}
		*/

		for(set<int>::iterator it=monitors_required.begin();it!=monitors_required.end();it++){
			ll monitors = *it;
			for(int j=0;j<(1<<problems);j++){
				dp[j]=MAX_COST;
			}
			current_state = 0;
			p_friends = 0;
			states_required1.clear();
			l_data.clear();
			for(int i=0;i<friends;i++){
				pair<set<int>::iterator,bool> it2;
				if(data[i].monitors <= monitors) {
				 it2 = states_required1.insert(data[i].state);
				 if(it2.second){
					 l_data.push_back(data[i]);
					 current_state |= data[i].state;
					 p_friends++;
				 }
				}
			}

			//			cout<<endl;
			//			cout<<endl;
			if(current_state == final_state && (states_required1!=states_required2)) {
				ll ans = solve(final_state);
				//cout<<ans<<endl;
				if(ans != MAX_COST) {
					//cout<<"------------------------"<<endl;
					min_ans = min(min_ans, (ans + (monitor_cost * monitors)));
					//cout<<"------------------------"<<endl;
				}
			}
			states_required2 = states_required1;
			//			cout<<endl;
			//			cout<<endl;
		}
		cout<<min_ans<<endl;
	}else{
		cout<<"-1"<<endl;
	}
	return 0;
}


#include<iostream>
#include<bitset>

#define ll unsigned long long int
#define MAX_STATE  (1<<20)+1

using namespace std;

class Data {
	public:
		Data()
		{
			int cost = 0;
			int monitors = 0;
			int problems = 0;
			int state = 0;
		}
		int cost;
		int monitors;
		int problems;
		int state;
};

int friends,problems,monitor_cost;
int final_state,current_state;
Data data[101];
ll MAX_COST = 1e19;
ll dp[MAX_STATE];

ll solve(int state,int total_monitors){
//		bitset<20> f(state);
//		cout<<"st"<<f<<endl;
	if(state == final_state){
		return 0;
	}
	if(dp[state]!=-1)
		return dp[state];

	ll ans = MAX_COST;
//	cout<<"----------------------S------------------"<<endl;
	for(int i=0;i<friends;i++){

//		cout<<"i= "<<i<<" "<<f<<endl;
		if((data[i].monitors <= total_monitors) && ((state & data[i].state) != data[i].state)) {
			ans = min(ans, (solve(state|data[i].state, total_monitors) + data[i].cost));
		}
//		cout<<"i= "<<i<<"ans= "<<ans<<" "<<f<<endl;
	}
//	cout<<"----------------------E------------------"<<endl;
	dp[state] = ans;
	return dp[state];
}

int main() {
	cin>>friends>>problems>>monitor_cost;
	final_state = (1<<problems)-1;
	current_state = 0;
	for(int i=0;i<friends;i++){
		cin>>data[i].cost>>data[i].monitors>>data[i].problems;
		for(int j=0;j<data[i].problems;j++){
			int p;
			cin>>p;
			current_state |= (1<<(p-1));
			data[i].state |= (1<<(p-1));
		}
//		cout<<"i= "<<i<<"state= "<<data[i].state<<endl;
	}
	ll min_ans = MAX_COST;
	if(current_state == final_state){
		for(int i=0;i<friends;i++){
			for(int j=0;j<(2*problems);j++){
				dp[j]=-1;
			}
//			cout<<endl;
//			cout<<endl;
			ll ans = solve(0, data[i].monitors);
//			cout<<ans<<endl;
			if(ans != MAX_COST) {
//				cout<<"------------------------"<<endl;
				min_ans = min(min_ans, (solve(0, data[i].monitors) + (monitor_cost * data[i].monitors)));
//				cout<<(ans + (monitor_cost * data[i].monitors))<<endl;
//				cout<<"------------------------"<<endl;
			}
//			cout<<endl;
//			cout<<endl;
		}
		cout<<min_ans<<endl;
	}else{
		cout<<"-1"<<endl;
	}
	return 0;
}


#include<iostream>
#include<bitset>
#include<set>

#define ll unsigned long long int
#define MAX_STATE  (1<<20)+1

using namespace std;

class Data {
	public:
		Data()
		{
			int cost = 0;
			int monitors = 0;
			int problems = 0;
			int state = 0;
		}
		int cost;
		int monitors;
		int problems;
		int state;
};

ll friends,problems,monitor_cost;
int final_state,current_state;
Data data[101];
ll MAX_COST = 1e19;
ll dp[MAX_STATE];

ll solve(int state,int total_monitors){
//		bitset<20> f(state);
//		cout<<"st"<<f<<endl;
	if(state == 0){
//		cout<<"-------"<<f<<endl;
		return 0;
	}
	if(dp[state]!=MAX_COST){
//		cout<<"&&&&&&&&&"<<f<<endl;
		return dp[state];
	}

	ll ans = MAX_COST;
//	cout<<"----------------------S------------------"<<endl;
	for(int i=0;i<friends;i++){

//		cout<<"i= "<<i<<" "<<f<<endl;
		if((data[i].monitors <= total_monitors) && ((state & data[i].state) != 0)) {
			ans = min(ans, (solve((state^(state&data[i].state)), total_monitors) + data[i].cost));
		}
//		cout<<"i= "<<i<<"ans= "<<ans<<" "<<f<<endl;
	}
//	cout<<"----------------------E------------------"<<endl;
	dp[state] = ans;
	return dp[state];
}

int main() {
	cin>>friends>>problems>>monitor_cost;
	final_state = (1<<problems)-1;
	current_state = 0;
	set<int> monitors_required;
	for(int i=0;i<friends;i++){
		cin>>data[i].cost>>data[i].monitors>>data[i].problems;
		for(int j=0;j<data[i].problems;j++){
			int p;
			cin>>p;
			current_state |= (1<<(p-1));
			data[i].state |= (1<<(p-1));
		}
		monitors_required.insert(data[i].monitors);
//		cout<<"i= "<<i<<"state= "<<data[i].state<<endl;
	}
	ll min_ans = MAX_COST;
	if(current_state == final_state){
		for(set<int>::iterator it=monitors_required.begin();it!=monitors_required.end();it++){
			for(int j=0;j<(1<<problems);j++){
				dp[j]=MAX_COST;
			}
//			cout<<endl;
//			cout<<endl;
			ll monitors = *it;
			ll ans = solve(final_state, monitors);
//			cout<<ans<<endl;
			if(ans != MAX_COST) {
//				cout<<"------------------------"<<endl;
				min_ans = min(min_ans, (ans + (monitor_cost * monitors)));
//				cout<<"------------------------"<<endl;
			}
//			cout<<endl;
//			cout<<endl;
		}
		cout<<min_ans<<endl;
	}else{
		cout<<"-1"<<endl;
	}
	return 0;
}


#include<algorithm>
#include<bitset>
#include<iostream>
#include<set>
#include<vector>

#define ll unsigned long long int
#define MAX_STATE  (1<<20)+1

using namespace std;

class Data {
	public:
		Data()
		{
			int cost = 0;
			int monitors = 0;
			int problems = 0;
			int state = 0;
		}
		int cost;
		int monitors;
		int problems;
		int state;
};

ll friends,problems,monitor_cost,p_friends;
int final_state,current_state;
vector<Data> data;
vector<Data> l_data;
ll MAX_COST = 1e19;
ll dp[MAX_STATE];

bool mycmp(Data a, Data b){
	if(a.state == b.state)
		return a.cost < b.cost;
	return a.state < b.state;
}

ll solve(int state){
	//		bitset<20> f(state);
	//		cout<<"st"<<f<<endl;
	if(state == 0){
		//		cout<<"-------"<<f<<endl;
		return 0;
	}
	if(dp[state]!=MAX_COST){
		//		cout<<"&&&&&&&&&"<<f<<endl;
		return dp[state];
	}

	ll ans = MAX_COST;
	//	cout<<"----------------------S------------------"<<endl;
	for(int i=0;i<p_friends;i++){

		//		cout<<"i= "<<i<<" "<<f<<endl;
		if ((state & l_data[i].state) != 0) {
			ans = min(ans, (solve(state ^ (state & l_data[i].state)) + l_data[i].cost));
		}
		//		cout<<"i= "<<i<<"ans= "<<ans<<" "<<f<<endl;
	}
	//	cout<<"----------------------E------------------"<<endl;
	dp[state] = ans;
	return dp[state];
}

int main() {
	cin>>friends>>problems>>monitor_cost;
	final_state = (1<<problems)-1;
	current_state = 0;
	set<int> monitors_required;
	set<int> states_required;
	for(int i=0;i<friends;i++){
		Data d;
		cin>>d.cost>>d.monitors>>d.problems;
		d.state = 0;
		for(int j=0;j<d.problems;j++){
			int p;
			cin>>p;
			current_state |= (1<<(p-1));
			d.state |= (1<<(p-1));
		}
		data.push_back(d);
		monitors_required.insert(d.monitors);
		//cout<<"i= "<<i<<"state= "<<data[i].state<<" "<<d.state<<" "<<endl;
	}
	if(current_state == final_state){
		ll min_ans = MAX_COST;
		sort(data.begin(),data.end(),mycmp);
		/*
		for(int i=0;i<friends;i++){
			cout<<data[i].state<<" "<<data[i].cost<<" "<<data[i].monitors<<" "<<data[i].problems<<endl;
		}
		*/

		for(set<int>::iterator it=monitors_required.begin();it!=monitors_required.end();it++){
			ll monitors = *it;
			for(int j=0;j<(1<<problems);j++){
				dp[j]=MAX_COST;
			}
			current_state = 0;
			p_friends = 0;
			states_required.clear();
			l_data.clear();
			for(int i=0;i<friends;i++){
				pair<set<int>::iterator,bool> it2;
				if(data[i].monitors <= monitors) {
				 it2 = states_required.insert(data[i].state);
				 if(it2.second){
					 l_data.push_back(data[i]);
					 current_state |= data[i].state;
					 p_friends++;
				 }
				}
			}
			//			cout<<endl;
			//			cout<<endl;
			if(current_state == final_state) {
				ll ans = solve(final_state);
				//cout<<ans<<endl;
				if(ans != MAX_COST) {
					//cout<<"------------------------"<<endl;
					min_ans = min(min_ans, (ans + (monitor_cost * monitors)));
					//cout<<"------------------------"<<endl;
				}
			}
			//			cout<<endl;
			//			cout<<endl;
		}
		cout<<min_ans<<endl;
	}else{
		cout<<"-1"<<endl;
	}
	return 0;
}


#include<algorithm>
#include<bitset>
#include<iostream>
#include<set>
#include<vector>

#define ll unsigned long long int
#define MAX_STATE  (1<<20)+1

using namespace std;

class Data {
	public:
		Data()
		{
			int cost = 0;
			int monitors = 0;
			int problems = 0;
			int state = 0;
		}
		int cost;
		int monitors;
		int problems;
		int state;
};

ll friends,problems,monitor_cost,p_friends;
int final_state,current_state;
vector<Data> data;
vector<Data> l_data;
vector<Data> r_data;
ll MAX_COST = 1e19;
ll dp[MAX_STATE];

bool mycmp(Data a, Data b){
	if(a.state == b.state)
		return a.cost < b.cost;
	return a.state < b.state;
}

ll solve(int state){
	//		bitset<20> f(state);
	//		cout<<"st"<<f<<endl;
	if(state == 0){
		//		cout<<"-------"<<f<<endl;
		return 0;
	}
	if(dp[state]!=MAX_COST){
		//		cout<<"&&&&&&&&&"<<f<<endl;
		return dp[state];
	}

	ll ans = MAX_COST;
	//	cout<<"----------------------S------------------"<<endl;
	for(int i=0;i<p_friends;i++){

		//		cout<<"i= "<<i<<" "<<f<<endl;
		if ((state & l_data[i].state) != 0) {
			ans = min(ans, (solve(state ^ (state & l_data[i].state)) + l_data[i].cost));
		}
		//		cout<<"i= "<<i<<"ans= "<<ans<<" "<<f<<endl;
	}
	//	cout<<"----------------------E------------------"<<endl;
	dp[state] = ans;
	return dp[state];
}

int main() {
	cin>>friends>>problems>>monitor_cost;
	final_state = (1<<problems)-1;
	current_state = 0;
	set<int> monitors_required;
	set<int> states_required;
	for(int i=0;i<friends;i++){
		Data d;
		cin>>d.cost>>d.monitors>>d.problems;
		d.state = 0;
		for(int j=0;j<d.problems;j++){
			int p;
			cin>>p;
			current_state |= (1<<(p-1));
			d.state |= (1<<(p-1));
		}
		data.push_back(d);
		monitors_required.insert(d.monitors);
		//cout<<"i= "<<i<<"state= "<<data[i].state<<" "<<d.state<<" "<<endl;
	}
	if(current_state == final_state){
		ll min_ans = MAX_COST;
		sort(data.begin(),data.end(),mycmp);
		/*
		for(int i=0;i<friends;i++){
			cout<<data[i].state<<" "<<data[i].cost<<" "<<data[i].monitors<<" "<<data[i].problems<<endl;
		}
		*/

		for(set<int>::iterator it=monitors_required.begin();it!=monitors_required.end();it++){
			ll monitors = *it;
			for(int j=0;j<(1<<problems);j++){
				dp[j]=MAX_COST;
			}
			current_state = 0;
			p_friends = 0;
			states_required.clear();
			l_data.clear();
			for(int i=0;i<friends;i++){
				pair<set<int>::iterator,bool> it2;
				if(data[i].monitors <= monitors) {
				 it2 = states_required.insert(data[i].state);
				 if(it2.second){
					 l_data.push_back(data[i]);
					 current_state |= data[i].state;
					 p_friends++;
				 }
				}
			}
			//			cout<<endl;
			//			cout<<endl;
			int flag=0;
			if(l_data.size() == r_data.size()){
				flag =1;
				for(int i=0;i<l_data.size();i++){
					if ((r_data[i].cost != l_data[i].cost)
					|| (r_data[i].problems != l_data[i].problems)
					|| (r_data[i].monitors != l_data[i].monitors)
					|| (r_data[i].state != l_data[i].state)){
						flag=0;
						break;
					}
				}
			}
			if(current_state == final_state && !flag) {
				ll ans = solve(final_state);
				//cout<<ans<<endl;
				if(ans != MAX_COST) {
					//cout<<"------------------------"<<endl;
					min_ans = min(min_ans, (ans + (monitor_cost * monitors)));
					//cout<<"------------------------"<<endl;
				}
			}
			r_data.clear();
			r_data = l_data;
			//			cout<<endl;
			//			cout<<endl;
		}
		cout<<min_ans<<endl;
	}else{
		cout<<"-1"<<endl;
	}
	return 0;
}


#include<iostream>
#include<bitset>

#define ll unsigned long long int
#define MAX_STATE  (1<<20)+1

using namespace std;

class Data {
	public:
		Data()
		{
			int cost = 0;
			int monitors = 0;
			int problems = 0;
			int state = 0;
		}
		int cost;
		int monitors;
		int problems;
		int state;
};

int friends,problems,monitor_cost;
int final_state,current_state;
Data data[101];
ll MAX_COST = 1e12;
ll dp[MAX_STATE] = {-1};

ll solve(int state,int total_monitors){
//		bitset<20> f(state);
//		cout<<"st"<<f<<endl;
	if(state == final_state){
		return 0;
	}
	ll ans = MAX_COST;
	ll cost;
	for(int i=0;i<friends;i++){
		if((data[i].monitors <= total_monitors) && ((state & data[i].state) != data[i].state)) {
			ans = min(MAX_COST, (solve(state|data[i].state, total_monitors) + data[i].cost));
		}
	}
//		cout<<ans<<" "<<f<<endl;
	return ans;
}

int main() {
	cin>>friends>>problems>>monitor_cost;
	final_state = (1<<problems)-1;
	current_state = 0;
	for(int i=0;i<friends;i++){
		cin>>data[i].cost>>data[i].monitors>>data[i].problems;
		for(int j=0;j<data[i].problems;j++){
			int p;
			cin>>p;
			current_state |= (1<<(p-1));
			data[i].state |= (1<<(p-1));
		}
//		cout<<"i= "<<i<<"state= "<<data[i].state<<endl;
	}
	ll min_ans = 1e19;
	if(current_state == final_state){
		for(int i=0;i<friends;i++){
			min_ans = (min_ans, (solve(0, data[i].monitors) + (monitor_cost * data[i].monitors)));
		}
		cout<<min_ans<<endl;
	}else{
		cout<<"-1"<<endl;
	}

	return 0;
}


#include<algorithm>
#include<bitset>
#include<iostream>
#include<set>
#include<vector>

#define ll unsigned long long int
#define MAX_STATE  (1<<20)+1

using namespace std;

class Data {
	public:
		Data()
		{
			int cost = 0;
			int monitors = 0;
			int problems = 0;
			int state = 0;
		}
		int cost;
		int monitors;
		int problems;
		int state;
};

ll friends,problems,monitor_cost,p_friends;
int final_state,current_state;
vector<Data> data;
ll MAX_COST = 1e19;
ll dp[MAX_STATE];

bool mycmp(Data a, Data b){
	return a.monitors < b.monitors;
}

int main() {
	cin>>friends>>problems>>monitor_cost;
	final_state = (1<<problems)-1;
	current_state = 0;
	set<int> monitors_required;
	set<int> states_required;
	for(int i=0;i<friends;i++){
		Data d;
		cin>>d.cost>>d.monitors>>d.problems;
		d.state = 0;
		for(int j=0;j<d.problems;j++){
			int p;
			cin>>p;
			current_state |= (1<<(p-1));
			d.state |= (1<<(p-1));
		}
		data.push_back(d);
	}
	if(current_state == final_state){
		sort(data.begin(),data.end(),mycmp);
		for(int j=0;j<(1<<problems);j++){
			dp[j]=MAX_COST;
		}
		ll ans = MAX_COST;
		dp[0] = 0;
		for(int i=0;i<friends;i++){
			for(int j=0;j<(1<<problems);j++){
				if(dp[j] != MAX_COST) {
					int state = (j | data[i].state);
					dp[state]=min(dp[state], dp[j]+data[i].cost);
				}
			}
			if(dp[final_state]!=MAX_COST){
				ans = min(ans, dp[final_state]+ data[i].monitors*monitor_cost);
			}
		}
		cout<<ans<<endl;
	}else{
		cout<<"-1"<<endl;
	}
	return 0;
}


#include<algorithm>
#include<iostream>
#include<vector>

#define ll unsigned long long int
#define MAX_STATE  (1<<20)+1

using namespace std;

class Data {
	public:
		Data()
		{
			int cost = 0;
			int monitors = 0;
			int problems = 0;
			int state = 0;
		}
		int cost;
		int monitors;
		int problems;
		int state;
};

ll friends,problems,monitor_cost,p_friends;
int final_state,current_state;
vector<Data> data;
ll MAX_COST = 1e19;
ll dp[MAX_STATE];

bool mycmp(Data a, Data b){
	return a.monitors < b.monitors;
}

int main() {
	cin>>friends>>problems>>monitor_cost;
	final_state = (1<<problems)-1;
	current_state = 0;
	for(int i=0;i<friends;i++){
		Data d;
		cin>>d.cost>>d.monitors>>d.problems;
		d.state = 0;
		for(int j=0;j<d.problems;j++){
			int p;
			cin>>p;
			current_state |= (1<<(p-1));
			d.state |= (1<<(p-1));
		}
		data.push_back(d);
	}
	if(current_state == final_state){
		sort(data.begin(),data.end(),mycmp);
		for(int j=0;j<(1<<problems);j++){
			dp[j]=MAX_COST;
		}
		ll ans = MAX_COST;
		dp[0] = 0;
		for(int i=0;i<friends;i++){
			for(int j=0;j<(1<<problems);j++){
				if(dp[j] != MAX_COST) {
					int state = (j | data[i].state);
					dp[state]=min(dp[state], dp[j]+data[i].cost);
				}
			}
			if(dp[final_state]!=MAX_COST){
				ans = min(ans, dp[final_state]+ data[i].monitors*monitor_cost);
			}
		}
		cout<<ans<<endl;
	}else{
		cout<<"-1"<<endl;
	}
	return 0;
}


#include<iostream>
#include<bitset>

#define ll unsigned long long int
#define MAX_STATE  (1<<20)+1

using namespace std;

class Data {
	public:
		Data()
		{
			int cost = 0;
			int monitors = 0;
			int problems = 0;
			int state = 0;
		}
		int cost;
		int monitors;
		int problems;
		int state;
};

ll friends,problems,monitor_cost;
int final_state,current_state;
Data data[101];
ll MAX_COST = 1e19;
ll dp[MAX_STATE];

ll solve(int state,int total_monitors){
//		bitset<20> f(state);
//		cout<<"st"<<f<<endl;
	if(state == final_state){
		return 0;
	}
	if(dp[state]!=-1)
		return dp[state];

	ll ans = MAX_COST;
//	cout<<"----------------------S------------------"<<endl;
	for(int i=0;i<friends;i++){

//		cout<<"i= "<<i<<" "<<f<<endl;
		if((data[i].monitors <= total_monitors) && ((state & data[i].state) != data[i].state)) {
			ans = min(ans, (solve(state|data[i].state, total_monitors) + data[i].cost));
		}
//		cout<<"i= "<<i<<"ans= "<<ans<<" "<<f<<endl;
	}
//	cout<<"----------------------E------------------"<<endl;
	dp[state] = ans;
	return dp[state];
}

int main() {
	cin>>friends>>problems>>monitor_cost;
	final_state = (1<<problems)-1;
	current_state = 0;
	for(int i=0;i<friends;i++){
		cin>>data[i].cost>>data[i].monitors>>data[i].problems;
		for(int j=0;j<data[i].problems;j++){
			int p;
			cin>>p;
			current_state |= (1<<(p-1));
			data[i].state |= (1<<(p-1));
		}
//		cout<<"i= "<<i<<"state= "<<data[i].state<<endl;
	}
	ll min_ans = MAX_COST;
	if(current_state == final_state){
		for(int i=0;i<friends;i++){
			for(int j=0;j<(2*problems);j++){
				dp[j]=-1;
			}
//			cout<<endl;
//			cout<<endl;
			ll ans = solve(0, data[i].monitors);
//			cout<<ans<<endl;
			if(ans != MAX_COST) {
//				cout<<"------------------------"<<endl;
				min_ans = min(min_ans, (solve(0, data[i].monitors) + (monitor_cost * data[i].monitors)));
//				cout<<(ans + (monitor_cost * data[i].monitors))<<endl;
//				cout<<"------------------------"<<endl;
			}
//			cout<<endl;
//			cout<<endl;
		}
		cout<<min_ans<<endl;
	}else{
		cout<<"-1"<<endl;
	}
	return 0;
}


#include<stdio.h>
#include <string.h>
#include <vector>
#include<map>
#include<stack>
#include <queue>
#include <set>
#include<limits.h>
#include <algorithm>
#include<iostream>
#define MAX 1003
#define INF 100000000
using namespace std;
//
class node
{
public:
    int cost , M ;
    int mas;
    node ( ) {};
    bool operator < (const node & e)const
    {
        return M < e.M;
    }
};
node arr[102];
unsigned long long   dp[2][1<<20];
int n , m , costMo,h,y;

int main()
{

    cin >> n >> m >> costMo;
    for(int i = 0 ; i <(1<<m); i++)
        dp[n&1][i]=INF;
    for(int i = 0 ; i <102; i++)
        dp[(int)(i&1)][(1<<m)-1]=0;

    for (int i=0; i<n; i++)
    {
        node s ;
        int G=0;
        cin >> s.cost  >> s.M >>  h;
        for (int j=0; j<h; j++)
        {
            cin >> y;
            G|=(1<<(y-1));
        }
        s.mas = G;
        arr[i]=s;
    }

    sort(arr,arr+n);
    for(int i = n-1 ; i>=0 ; i--)
        for(int j = (1<<m)-1; j>=0 ; j--)

        {
            unsigned long long  ch1 = INF , ch2 = INF ;
            ch1 = dp[(int)((i+1)&1) ][j];
            int  o =j;
            o|=arr[i].mas;
            if(o==(1<<m)-1)
                ch2 = arr[i].M*costMo + arr[i].cost + dp[(int)((i+1)&1)][ o];
            else
                ch2 = arr[i].cost + dp[(int)((i+1)&1)][o];

            dp[(int)((i)&1)][j]=min(ch1 , ch2);
        }
    unsigned long long  s =dp[0][0];
    if(s==INF)
        cout << -1 ;
    else
        cout << s;

    return 0;
}


#include<stdio.h>
#include <string.h>
#include <vector>
#include<map>
#include<stack>
#include <queue>
#include <set>
#include<limits.h>
#include <algorithm>
#include<iostream>
#define MAX 1003
#define INF 100000000
using namespace std;
//
class node
{
public:
    int cost , M ;
    int mas;
    node ( ) {};
    bool operator < (const node & e)const
    {
        return M < e.M;
    }
};
node arr[102];
long long  dp[101][1<<21];
int n , m , costMo,h,y;
long long  solve(int index , int mask )
{
    if(mask == (1<<m)-1)
        return 0;
    if(index == n )
        return INF ;
    if(dp[index][mask]!=-1)return dp[index][mask];
    long long  ch1 = INF , ch2 = INF ;
    ch1 = solve(index +1 , mask);
    int o =mask;
    o|=arr[index].mas;
    // cout << index << " "  << " " << arr[index].mas <<  " " << " " << mask << "  " << o <<endl;
    if(o==(1<<m)-1)
    {
        ch2 = arr[index].M*costMo + arr[index].cost + solve(index+1 , o);
    }
    else
    {
        ch2 = arr[index].cost + solve(index+1 , o);

    }
    return dp[index][mask]=min(ch1 , ch2 );
}

int main()
{

    fill(&dp[0][0],&dp[101][0],-1);

    cin >> n >> m >> costMo;
    for (int i=0; i<n; i++)
    {
        node s ;
        int G=0;
        cin >> s.cost  >> s.M >>  h;
        for (int j=0; j<h; j++)
        {
            cin >> y;
            G|=(1<<(y-1));
        }
        s.mas = G;
        arr[i]=s;
    }
    sort(arr,arr+n);

    long long s =solve(0,0);
    if(s==INF)
        cout << -1 ;
    else
        cout << s;
}
#include<stdio.h>
#include <string.h>
#include <vector>
#include<map>
#include<stack>
#include <queue>
#include <set>
#include<limits.h>
#include <algorithm>
#include<iostream>
#define MAX 1003
#define INF 100000000
using namespace std;
//
class node
{
public:
    int cost , M ;
    int mas;
    node ( ) {};
    bool operator < (const node & e)const
    {
        return M < e.M;
    }
};
node arr[102];
long long  dp[101][1<<21];
int n , m , costMo,h,y;
long long  solve(int index , int mask )
{
    if(mask == (1<<m)-1)
        return 0;
    if(index == n )
        return INF ;
    if(dp[index][mask]!=-1)return dp[index][mask];
    long long  ch1 = INF , ch2 = INF ;
    ch1 = solve(index +1 , mask);
    int o =mask;
    o|=arr[index].mas;
    // cout << index << " "  << " " << arr[index].mas <<  " " << " " << mask << "  " << o <<endl;
    if(o==(1<<m)-1)
    {
        ch2 = arr[index].M*costMo + arr[index].cost + solve(index+1 , o);
    }
    else
    {
        ch2 = arr[index].cost + solve(index+1 , o);

    }
    return dp[index][mask]=min(ch1 , ch2 );
}

int main()
{

    fill(&dp[0][0],&dp[101][0],-1);

    cin >> n >> m >> costMo;
    for (int i=0; i<n; i++)
    {
        node s ;
        int G=0;
        cin >> s.cost  >> s.M >>  h;
        for (int j=0; j<h; j++)
        {
            cin >> y;
            G|=(1<<(y-1));
        }
        s.mas = G;
        arr[i]=s;
    }
    sort(arr,arr+n);

    long long s =solve(0,0);
    if(s==INF)
        cout << -1 ;
    else
        cout << s;
}


#include <bits/stdc++.h>

using namespace std;
typedef pair<int, int> pii;
typedef vector<pair<int, int>> vii;
typedef vector<int> vi;
typedef long long ll;
typedef unsigned long long ull;
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a, b)
#define inf 0x3f3f3f3f

int princess[100010];
bool taken[100010];
vi noMatch;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;
    cin >> t;
    while (t--){
        int n, cnt = 0;
        cin >> n;
        for (int i = 0; i <= 100000; i++){
            princess[i] = 0;
            taken[i] = false;
        }
        noMatch.clear();
        for (int i = 1; i <= n; i++){
            princess[i] = inf;
            int k, g;
            bool flag = false;
            cin >> k;
            for (int j = 0; j < k; j++){
                cin >> g;
                if (!taken[g] && !flag){
                    princess[i] = g;
                    taken[g] = true;
                    flag = true;
                    cnt++;
                }
            }
            if (!flag) noMatch.pb(i);
        }
        if (cnt == n) cout << "OPTIMAL\n";
        else {
            bool improve = false;
            int last = 1;
            for (int i = 0; i < noMatch.size(); i++){
                if (improve) break;
                for (int j = last; j <= n; j++){
                    if (!taken[j]){
                        if (!improve) cout << "IMPROVE\n";
                        taken[j] = true;
                        cout << noMatch[i] << " " << j << "\n";
                        princess[i] = j;
                        improve = true;
                        break;
                    }
                }
            }
            if (!improve) cout << "OPTIMAL\n";
        }
    }
}


#include <bits/stdc++.h>

using namespace std;
typedef pair<int, int> pii;
typedef vector<pair<int, int>> vii;
typedef vector<int> vi;
typedef long long ll;
typedef unsigned long long ull;
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a, b)
#define inf 0x3f3f3f3f

bool taken[100010];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;
    cin >> t;
    while (t--){
        int n, cnt = 0;
        cin >> n;
        for (int i = 0; i <= 100000; i++){
            taken[i] = false;
        }
        int noMatch;
        for (int i = 1; i <= n; i++){
            int k, g;
            bool flag = false;
            cin >> k;
            for (int j = 0; j < k; j++){
                cin >> g;
                if (!taken[g] && !flag){
                    taken[g] = true;
                    flag = true;
                    cnt++;
                }
            }
            if (!flag) noMatch = i;
        }
        if (cnt == n) cout << "OPTIMAL\n";
        else {
            cout << "IMPROVE\n";
            for (int i = 1; i <= n; i++){
                if (!taken[i]){
                    cout << noMatch << " " << i << "\n";
                    break;
                }
            }
        }
    }
}


#include <bits/stdc++.h>

using namespace std;
typedef pair<int, int> pii;
typedef vector<pair<int, int>> vii;
typedef vector<int> vi;
typedef long long ll;
typedef unsigned long long ull;
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a, b)
#define inf 0x3f3f3f3f

bool taken[100010];
vi noMatch;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;
    cin >> t;
    while (t--){
        int n, cnt = 0;
        cin >> n;
        for (int i = 0; i <= 100000; i++){
            taken[i] = false;
        }
        noMatch.clear();
        for (int i = 1; i <= n; i++){
            int k, g;
            bool flag = false;
            cin >> k;
            for (int j = 0; j < k; j++){
                cin >> g;
                if (!taken[g] && !flag){
                    taken[g] = true;
                    flag = true;
                    cnt++;
                }
            }
            if (!flag) noMatch.pb(i);
        }
        if (cnt == n) cout << "OPTIMAL\n";
        else {
            bool improve = false;
            int last = 1;
            for (int i = 0; i < noMatch.size(); i++){
                if (improve) break;
                for (;last <= n; last++){
                    if (!taken[last]){
                        if (!improve) cout << "IMPROVE\n";
                        taken[last] = true;
                        cout << noMatch[i] << " " << last << "\n";
                        improve = true;
                        break;
                    }
                }
            }
            if (!improve) cout << "OPTIMAL\n";
        }
    }
}


#include <bits/stdc++.h>

using namespace std;
typedef pair<int, int> pii;
typedef vector<pair<int, int>> vii;
typedef vector<int> vi;
typedef long long ll;
typedef unsigned long long ull;
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a, b)
#define inf 0x3f3f3f3f

int princess[100010];
bool taken[100010];
vi noMatch;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;
    cin >> t;
    while (t--){
        int n, cnt = 0;
        cin >> n;
//        for (int i = 0; i <= 100000; i++){
//            princess[i] = 0;
//            taken[i] = false;
//        }
        noMatch.clear();
        for (int i = 1; i <= n; i++){
            princess[i] = inf;
            taken[i] = false;
            int k, g;
            bool flag = false;
            cin >> k;
            for (int j = 0; j < k; j++){
                cin >> g;
                if (!taken[g] && !flag){
                    princess[i] = g;
                    taken[g] = true;
                    flag = true;
                    cnt++;
                }
            }
            if (!flag) noMatch.pb(i);
        }
        if (cnt == n) cout << "OPTIMAL\n";
        else {
            bool improve = false;
            int last = 1;
            for (int i = 0; i < noMatch.size(); i++){
                if (improve) break;
                for (int j = last; j <= n; j++){
                    if (!taken[j]){
                        if (!improve) cout << "IMPROVE\n";
                        taken[j] = true;
                        cout << noMatch[i] << " " << j << "\n";
                        princess[i] = j;
                        improve = true;
                        break;
                    }
                }
            }
            if (!improve) cout << "OPTIMAL\n";
        }
    }
}


#include <bits/stdc++.h>

using namespace std;
typedef pair<int, int> pii;
typedef vector<pair<int, int>> vii;
typedef vector<int> vi;
typedef long long ll;
typedef unsigned long long ull;
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a, b)
#define inf 0x3f3f3f3f

bool taken[100010];
vi noMatch;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;
    cin >> t;
    while (t--){
        int n, cnt = 0;
        cin >> n;
        for (int i = 0; i <= n; i++){
            taken[i] = false;
        }
        noMatch.clear();
        for (int i = 1; i <= n; i++){
            int k, g;
            bool flag = false;
            cin >> k;
            for (int j = 0; j < k; j++){
                cin >> g;
                if (!taken[g] && !flag){
                    taken[g] = true;
                    flag = true;
                    cnt++;
                }
            }
            if (!flag) noMatch.pb(i);
        }
        if (cnt == n) cout << "OPTIMAL\n";
        else {
            bool improve = false;
            int last = 1;
            for (int i = 0; i < noMatch.size(); i++){
                if (improve) break;
                for (;last <= n; last++){
                    if (!taken[last]){
                        if (!improve) cout << "IMPROVE\n";
                        taken[last] = true;
                        cout << noMatch[i] << " " << last << "\n";
                        improve = true;
                        break;
                    }
                }
            }
            if (!improve) cout << "OPTIMAL\n";
        }
    }
}


#include <bits/stdc++.h>

using namespace std;
typedef pair<int, int> pii;
typedef vector<pair<int, int>> vii;
typedef vector<int> vi;
typedef long long ll;
typedef unsigned long long ull;
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a, b)
#define inf 0x3f3f3f3f

int princess[100010];
bool taken[100010];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;
    cin >> t;
    while (t--){
        int n, cnt = 0;
        cin >> n;
        for (int i = 0; i <= 100000; i++){
            princess[i] = 0;
            taken[i] = false;
        }
        for (int i = 1; i <= n; i++){
            princess[i] = inf;
            int k, g;
            bool flag = false;
            cin >> k;
            for (int j = 0; j < k; j++){
                cin >> g;
                if (!taken[g] && !flag){
                    princess[i] = g;
                    taken[g] = true;
                    flag = true;
                    cnt++;
                }
            }
        }
        if (cnt == n) cout << "OPTIMAL\n";
        else {
            bool improve = false;
            int last = 1;
            for (int i = 1; i <= n; i++){
                if (improve) break;
                if (princess[i] == inf){
                    for (int j = last; j <= n; j++){
                        if (!taken[j]){
                            if (!improve) cout << "IMPROVE\n";
                            taken[j] = true;
                            cout << i << " " << j << "\n";
                            princess[i] = j;
                            improve = true;
                            break;
                        }
                    }
                }
            }
            if (!improve) cout << "OPTIMAL\n";
        }
    }
}


/*
5
4
2 2 3
2 1 2
2 3 4
1 3
2
0
0
3
3 1 2 3
3 1 2 3
3 1 2 3
1
1 1
4
1 1
1 2
1 3
1 4
*/
#include<bits/stdc++.h>
using namespace std;
#define endl "\n"
typedef long long ll;
bool vis[(int)1e5+5];
bool merry[(int)1e5+5];
int num[(int)1e5+5];
int main(){
    std::ios::sync_with_stdio(false);
    int t;cin>>t;
    while(t--){
        int n;cin>>n;
        ///vector<int>data[n+5];
        for(int i=1;i<=n;i++)vis[i]=0,merry[i]=0;
        for(int i=1;i<=n;i++){
            cin>>num[i];bool f=1;
            for(int j=0;j<num[i];j++){
                int x;cin>>x;
                if(!vis[x]&&f){
                    merry[i]=1,vis[x]=1;
                    f=0;
                }
            }
        }
        int point=1;bool flag=0;
        vector<pair<int,int> >ans;
        for(int i=1;i<=n;i++){
            if(merry[i])continue;
            while(vis[point]&&point<=n)point++;
            if(point<=n&&vis[point]==0){
                ans.push_back({i,point});
                break;
            }
            else {
                flag=1;
                break;
            }
        }
        if(flag||ans.empty())cout<<"OPTIMAL"<<endl;
        else{
            cout<<"IMPROVE"<<endl;
            cout<<ans[0].first<<" "<<ans[0].second<<endl;
        }
    }
}


/*
5
4
2 2 3
2 1 2
2 3 4
1 3
2
0
0
3
3 1 2 3
3 1 2 3
3 1 2 3
1
1 1
4
1 1
1 2
1 3
1 4
*/
#include<bits/stdc++.h>
using namespace std;
#define endl "\n"
typedef long long ll;
bool vis[(int)1e5+5];
int num[(int)1e5+5];
int main(){
    //std::ios::sync_with_stdio(false);
    int t;cin>>t;
    while(t--){
        int n,k,x;cin>>n;
        vector<int>data[n+5];
        for(int i=1;i<=n;i++){
            cin>>num[i];vis[i]=0;
            for(int j=0;j<num[i];j++){
                cin>>x;
                data[i].push_back(x);
            }
        }
        int point=1;bool flag=0;
        vector<pair<int,int> >ans;
        for(int i=1;i<=n;i++){
            int j=0;
            if(num[i]==0){
                while(vis[point]&&point<=n)point++;
                if(point<=n&&vis[point]==0){
                    vis[point]=1;
                    ans.push_back({i,point});
                    break;
                }
                else {
                    flag=1;
                    break;
                }
                continue;
            }
            while(vis[data[i][j]]&&j<num[i])j++;
            //cout<<" "<<j<<endl;
            if(j<num[i]&&vis[data[i][j]]==0)vis[data[i][j]]=1;
            else{
                while(vis[point]&&point<=n)point++;
                //cout<<i<<" "<<point<<endl;
                if(point<=n&&vis[point]==0){
                    vis[point]=1;
                    ans.push_back({i,point});
                    break;
                }
                else {
                    flag=1;
                    break;
                }
            }
        }
        if(flag||ans.empty())cout<<"OPTIMAL"<<endl;
        else{
            cout<<"IMPROVE"<<endl;
            cout<<ans[0].first<<" "<<ans[0].second<<endl;
        }
    }
}


/*
5
4
2 2 3
2 1 2
2 3 4
1 3
2
0
0
3
3 1 2 3
3 1 2 3
3 1 2 3
1
1 1
4
1 1
1 2
1 3
1 4
*/
#include<bits/stdc++.h>
using namespace std;
#define endl "\n"
typedef long long ll;
bool vis[(int)1e5+5];
bool merry[(int)1e5+5];
int num[(int)1e5+5];
int main(){
    std::ios::sync_with_stdio(false);
    int t;cin>>t;
    while(t--){
        int n,k,x;//cin>>n;
        cin>>n;
        ///vector<int>data[n+5];
        for(int i=1;i<=n;i++){
            cin>>num[i];
            vis[i]=0;merry[i]=0;
            for(int j=0;j<num[i];j++){
                int x;cin>>x;
                if(!vis[x])merry[i]=1,vis[x]=1;
            }
        }
        int point=1;bool flag=0;
        vector<pair<int,int> >ans;
        for(int i=1;i<=n;i++){
            if(merry[i])continue;
            while(vis[point]&&point<=n)point++;
            if(point<=n&&vis[point]==0){
                ans.push_back({i,point});
                break;
            }
            else {
                flag=1;
                break;
            }
        }
        if(flag||ans.empty())cout<<"OPTIMAL"<<endl;
        else{
            cout<<"IMPROVE"<<endl;
            cout<<ans[0].first<<" "<<ans[0].second<<endl;
        }
    }
}


/*
5
4
2 2 3
2 1 2
2 3 4
1 3
2
0
0
3
3 1 2 3
3 1 2 3
3 1 2 3
1
1 1
4
1 1
1 2
1 3
1 4
*/
#include<bits/stdc++.h>
using namespace std;
#define endl "\n"
typedef long long ll;
bool vis[(int)1e5+5];
int num[(int)1e5+5];
int main(){
    std::ios::sync_with_stdio(false);
    int t;cin>>t;
    while(t--){
        int n,k,x;cin>>n;
        vector<int>data[n+5];
        for(int i=1;i<=n;i++){
            cin>>num[i];vis[i]=0;
            for(int j=0;j<num[i];j++){
                cin>>x;
                data[i].push_back(x);
            }
        }
        int point=1;bool flag=0;
        vector<pair<int,int> >ans;
        for(int i=1;i<=n;i++){
            int j=0;
            if(num[i]==0){
                while(vis[point]&&point<=n)point++;
                if(point<=n&&vis[point]==0){
                    vis[point]=1;
                    ans.push_back({i,point});
                    break;
                }
                else {
                    flag=1;
                    break;
                }
                continue;
            }
            while(vis[data[i][j]]&&j<num[i])j++;
            //cout<<" "<<j<<endl;
            if(j<num[i]&&vis[data[i][j]]==0)vis[data[i][j]]=1;
            else{
                while(vis[point]&&point<=n)point++;
                //cout<<i<<" "<<point<<endl;
                if(point<=n&&vis[point]==0){
                    vis[point]=1;
                    ans.push_back({i,point});
                    break;
                }
                else {
                    flag=1;
                    break;
                }
            }
        }
        if(flag||ans.empty())cout<<"OPTIMAL"<<endl;
        else{
            cout<<"IMPROVE"<<endl;
            cout<<ans[0].first<<" "<<ans[0].second<<endl;
        }
    }
}


/*
5
4
2 2 3
2 1 2
2 3 4
1 3
2
0
0
3
3 1 2 3
3 1 2 3
3 1 2 3
1
1 1
4
1 1
1 2
1 3
1 4
*/
#include<bits/stdc++.h>
using namespace std;
#define endl "\n"
typedef long long ll;
bool vis[(int)1e5+5];
int num[(int)1e5+5];
int main(){
    std::ios::sync_with_stdio(false);
    int t;cin>>t;
    while(t--){
        int n,k,x;cin>>n;
        vector<int>data[n+5];
        for(int i=0;i<n;i++){
            cin>>num[i];vis[i]=0;
            for(int j=0;j<num[i];j++){
                cin>>x;
                data[i].push_back(x-1);
            }
        }
        int point=0;bool flag=0;
        vector<pair<int,int> >ans;
        for(int i=0;i<n;i++){
            int j=0;
            if(num[i]==0){
                while(vis[point]&&point<n)point++;
                if(point<n&&vis[point]==0){
                    vis[point]=1;
                    ans.push_back({i+1,point+1});
                    break;
                }
                else {
                    flag=1;
                    break;
                }
                continue;
            }
            while(vis[data[i][j]]&&j<num[i])j++;
            //cout<<" "<<j<<endl;
            if(j<num[i]&&vis[data[i][j]]==0)vis[data[i][j]]=1;
            else{
                while(vis[point]&&point<n)point++;
                //cout<<i<<" "<<point<<endl;
                if(point<n&&vis[point]==0){
                    vis[point]=1;
                    ans.push_back({i+1,point+1});
                    break;
                }
                else {
                    flag=1;
                    break;
                }
            }
        }
        if(flag||ans.empty())cout<<"OPTIMAL"<<endl;
        else{
            cout<<"IMPROVE"<<endl;
            cout<<ans[0].first<<" "<<ans[0].second<<endl;
        }
    }
}


/*
5
4
2 2 3
2 1 2
2 3 4
1 3
2
0
0
3
3 1 2 3
3 1 2 3
3 1 2 3
1
1 1
4
1 1
1 2
1 3
1 4
*/
#include<bits/stdc++.h>
using namespace std;
#define endl "\n"
typedef long long ll;
bool vis[(int)1e5+5];
vector<int>data[(int)1e5+5];
bool merry[(int)1e5+5];
int num[(int)1e5+5];
int main(){
    std::ios::sync_with_stdio(false);
    int t;cin>>t;
    while(t--){
        int n,k,x;cin>>n;
        ///vector<int>data[n+5];
        for(int i=1;i<=n;i++){
            data[i].clear();
            cin>>num[i];vis[i]=0;merry[i]=0;
            for(int j=0;j<num[i];j++){
                cin>>x;
                data[i].push_back(x);
            }
        }
        int point=1;bool flag=0;
        vector<pair<int,int> >ans;
        for(int i=1;i<=n;i++){
            int j=0;
            while(vis[data[i][j]]&&j<num[i])j++;
            //cout<<" "<<j<<endl;
            if(j>=num[i])continue;
            if(vis[data[i][j]]==0)vis[data[i][j]]=1,merry[i]=1;
        }
        for(int i=1;i<=n;i++){
            if(merry[i])continue;
            int j=0;
            while(vis[point]&&point<=n)point++;
            if(point<=n&&vis[point]==0){
                ans.push_back({i,point});
                break;
            }
            else {
                flag=1;
                break;
            }
        }
        if(flag||ans.empty())cout<<"OPTIMAL"<<endl;
        else{
            cout<<"IMPROVE"<<endl;
            cout<<ans[0].first<<" "<<ans[0].second<<endl;
        }
    }
}


/*
5
4
2 2 3
2 1 2
2 3 4
1 3
2
0
0
3
3 1 2 3
3 1 2 3
3 1 2 3
1
1 1
4
1 1
1 2
1 3
1 4
*/
#include<bits/stdc++.h>
using namespace std;
#define endl "\n"
typedef long long ll;
bool vis[(int)1e5+5];
vector<int>data[(int)1e5+5];
int num[(int)1e5+5];
int main(){
    std::ios::sync_with_stdio(false);
    int t;cin>>t;
    while(t--){
        int n,k,x;cin>>n;
        ///vector<int>data[n+5];
        for(int i=1;i<=n;i++){
            data[i].clear();
            cin>>num[i];vis[i]=0;
            for(int j=0;j<num[i];j++){
                cin>>x;
                data[i].push_back(x);
            }
        }
        int point=1;bool flag=0;
        vector<pair<int,int> >ans;
        for(int i=1;i<=n;i++){
            int j=0;
            if(num[i]==0){
                while(vis[point]&&point<=n)point++;
                if(point<=n&&vis[point]==0){
                    vis[point]=1;
                    ans.push_back({i,point});
                    break;
                }
                else {
                    flag=1;
                    break;
                }
                continue;
            }
            while(vis[data[i][j]]&&j<num[i])j++;
            //cout<<" "<<j<<endl;
            if(j<num[i]&&vis[data[i][j]]==0)vis[data[i][j]]=1;
            else{
                while(vis[point]&&point<=n)point++;
                //cout<<i<<" "<<point<<endl;
                if(point<=n&&vis[point]==0){
                    vis[point]=1;
                    ans.push_back({i,point});
                    break;
                }
                else {
                    flag=1;
                    break;
                }
            }
        }
        if(flag||ans.empty())cout<<"OPTIMAL"<<endl;
        else{
            cout<<"IMPROVE"<<endl;
            cout<<ans[0].first<<" "<<ans[0].second<<endl;
        }
    }
}


/*
5
4
2 2 3
2 1 2
2 3 4
1 3
2
0
0
3
3 1 2 3
3 1 2 3
3 1 2 3
1
1 1
4
1 1
1 2
1 3
1 4
*/
#include<bits/stdc++.h>
using namespace std;
#define endl "\n"
typedef long long ll;
bool vis[(int)1e5+5];
vector<int>data[(int)1e5+5];
bool merry[(int)1e5+5];
int num[(int)1e5+5];
int main(){
    std::ios::sync_with_stdio(false);
    int t;cin>>t;
    while(t--){
        int n,k,x;cin>>n;
        ///vector<int>data[n+5];
        for(int i=1;i<=n;i++){
            data[i].clear();
            cin>>num[i];vis[i]=0;merry[i]=0;
            for(int j=0;j<num[i];j++){
                cin>>x;
                data[i].push_back(x);
            }
        }
        int point=1;bool flag=0;
        vector<pair<int,int> >ans;
        for(int i=1;i<=n;i++){
            int j=0;
            while(vis[data[i][j]]&&j<num[i])j++;
            //cout<<" "<<j<<endl;
            if(j<num[i]&&vis[data[i][j]]==0)vis[data[i][j]]=1,merry[i]=1;
        }
        for(int i=1;i<=n;i++){
            if(merry[i])continue;
            int j=0;
            while(vis[point]&&point<=n)point++;
            if(point<=n&&vis[point]==0){
                ans.push_back({i,point});
                break;
            }
            else {
                flag=1;
                break;
            }
        }
        if(flag||ans.empty())cout<<"OPTIMAL"<<endl;
        else{
            cout<<"IMPROVE"<<endl;
            cout<<ans[0].first<<" "<<ans[0].second<<endl;
        }
    }
}


#include<bits/stdc++.h>
using namespace std;
const int N=1e6+6;
int used[N];
void calc(int n){
	for(int i=1;i<=n;i++){
		used[i]=0;
	}
}
int main(){
	long long T;
	cin>>T;
	while(T--){
		int n;
		cin>>n;
		int ddd=0;
		for(int i=1;i<=n;i++){
			int p;
			cin>>p;
			bool flag=1;
			for(int j=1;j<=p;j++){
				int ppp;
				cin>>ppp;
				if(used[ppp]==0&&flag==1){
					used[ppp]=1;
					flag=0;
				}
			}
			if(flag==1)ddd=i;
		}
		if(ddd==0){
			cout<<"OPTIMAL"<<endl;
			calc(n);
			continue;
		}
		bool flag1=0;
		for(int i=1;i<=n;i++){
			if(!used[i]){
				cout<<"IMPROVE"<<endl;
				cout<<ddd<<" "<<i<<endl;
				flag1=1;
				break;
			}
		}
		if(flag1==1){
			calc(n);
			continue;
		}
		cout<<"OPTIMAL"<<endl;
		calc(n);
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define PII pair<int,int>
#define fr(i,a,b) for(int i=a;i<=b;i++)
#define fo(i,a,b) for(int i=a;i>=b;i--)
//#pragma GCC optimize(2)
int t,n,f1[100005],f2[100005];
int main(){
	scanf("%d",&t);
	while(t--){
		int sum=0;
		memset(f1,0,sizeof(f1));
		memset(f2,0,sizeof(f2));
		scanf("%d",&n);
		fr(i,1,n){
			int g;
			scanf("%d",&g);
			int flag=0;
			fr(j,1,g){
				int x;
				scanf("%d",&x);
				if(f2[x]==0&&flag==0) {
					f2[x]=1;
					f1[i]=1;
					flag=1;
					sum++;
				}
			}
		}
		if(sum==n){
			printf("OPTIMAL\n");
		}
		else{
			printf("IMPROVE\n");
			fr(i,1,n)
				if(f1[i]==0) {
					printf("%d ",i);
					break;
				}
			fr(i,1,n)
				if(f2[i]==0) {
					printf("%d\n",i);
					break;
				}
		}
	}
	return 0;
}


#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int maxn = 2e5 + 5;

int main() {
	ios::sync_with_stdio(false);
	int t;
	cin >> t;
	while(t--) {
		int n;
		cin >> n;
		int a[maxn] = {0};
		int ans = 0;

		for(int i = 1; i <= n; i++) {
			int cnt;
			cin >> cnt;

			int flag = 0;
			for(int j = 1; j <= cnt; j++) {
				int v;
				cin >> v;
				if(a[v] == 0 && flag == 0) {
					a[v] = 1;
					flag = 1;
				}
			}
			if(flag == 0) {
				ans = i;
			}
		}

		if(ans == 0) {
			cout << "OPTIMAL" << endl;
		} else {
			cout << "IMPROVE" << endl;
			for(int j = 1; j <= n; j++) {
				if(a[j] == 0) {
					cout << ans << ' ' << j << endl;
					break;
				}
			}
		}
	}

	return 0;
}


#include<bits/stdc++.h>
using namespace std;
bool a[100003],b[100003];
int main()
{
    int t;
    scanf("%d",&t);
    while(t--)
    {
        int n,t,k;
        scanf("%d",&n);
        for(int i=1; i<=n; i++)
        {
            bool f=1;
            scanf("%d",&k);

            for(int j=1; j<=k; j++)
            {
                cin>>t;
                if((!a[t]) &&f) {
                    b[i]=a[t]=1;
                    f=0;
                }
        }
    }
    int x=0,y=0;
    for(int i=1; i<=n; i++) if(!a[i])
    {
        x=i; break;
    }
    for(int i=1; i<=n; i++) if(!b[i])
    {
        y=i; break;
    }
    if(x && y)
    printf("IMPROVE\n%d %d\n",y,x);
    else printf("OPTIMAL\n");
    for(int i=1; i<=n; i++) a[i]=b[i]=0;
    }
    return 0;
}


#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<iomanip>
using namespace std;
int k[100010],b[100010];
int ans=0,n;
int main()
{
	int t;
	cin>>t;
	while(t--)
	{
		cin>>n;
		for(int i=1;i<=n;i++)
		{
			cin>>k[i];
			int flag=0;
			for(int j=1;j<=k[i];j++)
			{
				int x;
				cin>>x;
				if(b[x]==0&&flag==0)
				{
					b[x]++;
					flag=1;
				}
			}
			if(flag==0)
			ans=i;
		}
		if(!ans)
		{
			cout<<"OPTIMAL"<<endl;
			continue;
		}
		cout<<"IMPROVE"<<endl;
		for(int i=1;i<=n;i++)
		{
			if(b[i]==0)
			{
				cout<<ans<<" "<<i<<endl;
				break;
			}
		}
	}
	return 0;
}