inf=10**9
import sys
input=sys.stdin.readline
n,m=map(int,input().split())
dp=[[inf]*(2**n) for _ in range(m+1)]
def two(i):
	return "0"*(n-len(bin(i)[2:]))+bin(i)[2:]
for i in range(m+1):
	dp[i][0]=0
for i in range(m):
	a,b=map(int,input().split())
	r=0
	c=list(map(int,input().split()))
	for p in c:
		r+=2**(p-1)
	for j in range(2**n):
		x=j|r
		dp[i+1][x]=min(dp[i][j]+a,dp[i][x],dp[i+1][x])
	for j in range(2**n):
		dp[i+1][j]=min(dp[i+1][j],dp[i][j])
print(dp[-1][-1]) if dp[-1][-1]!=inf else print(-1) inf=10**9 inf 10**9 10 9 import sys sys input=sys.stdin.readline input sys.stdin.readline sys.stdin sys stdin readline n,m=map(int,input().split()) n map(int,input().split()) map int input().split() ().split () input split m [inf]*(2**n) for _ in range(m+1) for _ in range(m+1) _ range(m+1) range m+1 m 1 for _ in range(m+1) [inf]*(2**n) [inf] inf 2**n 2 n dp=[[inf]*(2**n) for _ in range(m+1)] dp [[inf]*(2**n) for _ in range(m+1)] def two(i):
	return "0"*(n-len(bin(i)[2:]))+bin(i)[2:] two return "0"*(n-len(bin(i)[2:]))+bin(i)[2:] "0"*(n-len(bin(i)[2:]))+bin(i)[2:] "0"*(n-len(bin(i)[2:])) "0" n-len(bin(i)[2:]) n len(bin(i)[2:]) len bin(i)[2:] (i) bin i 2: 2 bin(i)[2:] (i) bin i 2: 2 i i for i in range(m+1):
	dp[i][0]=0 i range(m+1) range m+1 m 1 dp[i][0]=0 dp[i][0] [i] dp i 0 0 for i in range(m):
	a,b=map(int,input().split())
	r=0
	c=list(map(int,input().split()))
	for p in c:
		r+=2**(p-1)
	for j in range(2**n):
		x=j|r
		dp[i+1][x]=min(dp[i][j]+a,dp[i][x],dp[i+1][x])
	for j in range(2**n):
		dp[i+1][j]=min(dp[i+1][j],dp[i][j]) i range(m) range m a,b=map(int,input().split()) a map(int,input().split()) map int input().split() ().split () input split b r=0 r 0 c=list(map(int,input().split())) c list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split for p in c:
		r+=2**(p-1)
	 p c r+=2**(p-1) r 2**(p-1) 2 p-1 p 1 for j in range(2**n):
		x=j|r
		dp[i+1][x]=min(dp[i][j]+a,dp[i][x],dp[i+1][x])
	 j range(2**n) range 2**n 2 n x=j|r x j|r j r dp[i+1][x]=min(dp[i][j]+a,dp[i][x],dp[i+1][x]) dp[i+1][x] [i+1] dp i+1 i 1 x min(dp[i][j]+a,dp[i][x],dp[i+1][x]) min dp[i][j]+a dp[i][j] [i] dp i j a dp[i][x] [i] dp i x dp[i+1][x] [i+1] dp i+1 i 1 x for j in range(2**n):
		dp[i+1][j]=min(dp[i+1][j],dp[i][j]) j range(2**n) range 2**n 2 n dp[i+1][j]=min(dp[i+1][j],dp[i][j]) dp[i+1][j] [i+1] dp i+1 i 1 j min(dp[i+1][j],dp[i][j]) min dp[i+1][j] [i+1] dp i+1 i 1 j dp[i][j] [i] dp i j print(dp[-1][-1]) if dp[-1][-1]!=inf else print(-1) dp[-1][-1]!=inf dp[-1][-1] [-1] dp -1 -1 inf print(dp[-1][-1]) print dp[-1][-1] [-1] dp -1 -1 print(-1) print -1 m=map(int,input().split()) map(int,input().split()) m a,b=map(int,input().split()) map(int,input().split()) a b=map(int,input().split()) map(int,input().split()) b inf=10**9 10**9 inf r=0 0 r input=sys.stdin.readline sys.stdin.readline input c=list(map(int,input().split())) list(map(int,input().split())) c dp=[[inf]*(2**n) for _ in range(m+1)] [[inf]*(2**n) for _ in range(m+1)] dp x=j|r j|r x n,m=map(int,input().split()) map(int,input().split()) n r+=2**(p-1) 2**(p-1) r def two(i):
	return "0"*(n-len(bin(i)[2:]))+bin(i)[2:] def two(i):
	return "0"*(n-len(bin(i)[2:]))+bin(i)[2:] two
inf=10**9
import sys
input=sys.stdin.readline
n,m=map(int,input().split())
dp=[[inf]*(2**n) for _ in range(m+1)]
def two(i):
	return "0"*(n-len(bin(i)[2:]))+bin(i)[2:]
for i in range(m+1):
	dp[i][0]=0
for i in range(m):
	a,b=map(int,input().split())
	r=0
	c=list(map(int,input().split()))
	for p in c:
		r+=2**(p-1)
	for j in range(2**n):
		x=j|r
		dp[i+1][x]=min(dp[i][j]+a,dp[i][x],dp[i+1][x])
	for j in range(2**n):
		dp[i+1][j]=min(dp[i+1][j],dp[i][j])
print(dp[-1][-1]) if dp[-1][-1]!=inf else print(-1)