#include <algorithm>
#include <cmath>
#include <cstdio>
#include <climits>
#include <cstring>
using namespace std;
int n,m,dp[1<<12],maxstate;
int main(){
	scanf("%d%d",&n,&m);
	maxstate=(1<<n)-1;
	for(register int i=1;i<=maxstate;i++)	dp[i]=INT_MAX;
	for(register int i=1;i<=m;i++){
		int a,b,c,now=0;
		scanf("%d%d",&a,&b);
		for(register int j=1;j<=b;j++){
			scanf("%d",&c),now|=(1<<(c-1));
		}
		for(register int j=maxstate;j>=0;j--)	if(dp[j]!=INT_MAX) dp[j|now]=min(dp[j]+a,dp[j|now]);
	}
	if(dp[maxstate]==INT_MAX)	printf("-1");
	else printf("%d",dp[maxstate]);
	return 0;
}