#include<cstdio>
#include<cstdlib>
#include<cstring>
#define rnt register int
using namespace std;
int dp[1<<13],n,m,t;
int w[1010],b,d[1010];
int main()
{
	memset(dp,0x3f,sizeof(dp));
	scanf("%d %d",&n,&m);
	for(rnt i=0;i<m;i=-~i)
	{
		scanf("%d %d",&w[i],&b);
		for(rnt j=0;j<b;j=-~j)
		{
			scanf("%d",&t);
			d[i]|=1<<t-1;
		}
	}dp[0]=0;
	for(rnt i=0;i<=(1<<n)-1;i=-~i)
		for(rnt j=0;j<m;j=-~j)
			if(dp[i]+w[j]<dp[i|d[j]])
				dp[i|d[j]]=dp[i]+w[j];
	if(dp[(1<<n)-1]>=1e9) puts("-1");
	else printf("%d",dp[(1<<n)-1]);
	return 0;
}