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

void wybzdjsmjjfbgtn(int &d,int p,int a)
{
	if(p<0)
		return;
	if(d<0||d>p+a)
		d=p+a;
}

signed main()
{
	int N,M;
	cin>>N>>M;
	int T=1<<N;
	vector<int> dp(T,-1);
	dp[0]=0;
	while(M--)
	{
		int a,b,key=0,S=T;
		cin>>a>>b;
		while(b--)
		{
			int c;
			cin>>c;
			c--;
			key|=1<<c;
		}
		while(S--)
			wybzdjsmjjfbgtn(dp[S|key],dp[S],a);
	}
	cout<<dp[T-1]<<endl;
}