n, m = map(int, input().split())
valists = [10**9 for _ in range(1<<n)]
valists[0] = 0
for i in range(m):
	values, b = map(int, input().split())
	c = list(map(int, input().split()))
	cnt = 0
	for j in range(b):
		cnt += 2**(c[j]-1)
	for j in range(len(valists)):
		x = j|cnt
		valists[x] = min(valists[x], valists[j]+values)
		#print(j, cnt, x, valists)

#print(valists)
ans = valists[2**n-1]
if ans != 10**9:
	print(ans)
else:
	print(-1) n, m = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split m 10**9 for _ in range(1<<n) for _ in range(1<<n) _ range(1<<n) range 1<<n 1 n for _ in range(1<<n) 10**9 10 9 valists = [10**9 for _ in range(1<<n)] valists [10**9 for _ in range(1<<n)] valists[0] = 0 valists[0] valists 0 0 for i in range(m):
	values, b = map(int, input().split())
	c = list(map(int, input().split()))
	cnt = 0
	for j in range(b):
		cnt += 2**(c[j]-1)
	for j in range(len(valists)):
		x = j|cnt
		valists[x] = min(valists[x], valists[j]+values)
		#print(j, cnt, x, valists)

#print(valists) i range(m) range m values, b = map(int, input().split()) values map(int, input().split()) map int input().split() ().split () input split b c = list(map(int, input().split())) c list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split cnt = 0 cnt 0 for j in range(b):
		cnt += 2**(c[j]-1)
	 j range(b) range b cnt += 2**(c[j]-1) cnt 2**(c[j]-1) 2 c[j]-1 c[j] c j 1 for j in range(len(valists)):
		x = j|cnt
		valists[x] = min(valists[x], valists[j]+values)
		#print(j, cnt, x, valists)

#print(valists) j range(len(valists)) range len(valists) len valists x = j|cnt x j|cnt j cnt valists[x] = min(valists[x], valists[j]+values) valists[x] valists x min(valists[x], valists[j]+values) min valists[x] valists x valists[j]+values valists[j] valists j values ans = valists[2**n-1] ans valists[2**n-1] valists 2**n-1 2**n 2 n 1 if ans != 10**9:
	print(ans)
else:
	print(-1) ans != 10**9 ans 10**9 10 9 print(ans) print ans print(-1) print -1 b = map(int, input().split()) map(int, input().split()) b values, b = map(int, input().split()) map(int, input().split()) values n, m = map(int, input().split()) map(int, input().split()) n c = list(map(int, input().split())) list(map(int, input().split())) c ans = valists[2**n-1] valists[2**n-1] ans cnt = 0 0 cnt x = j|cnt j|cnt x cnt += 2**(c[j]-1) 2**(c[j]-1) cnt m = map(int, input().split()) map(int, input().split()) m valists = [10**9 for _ in range(1<<n)] [10**9 for _ in range(1<<n)] valists
n, m = map(int, input().split())
valists = [10**9 for _ in range(1<<n)]
valists[0] = 0
for i in range(m):
	values, b = map(int, input().split())
	c = list(map(int, input().split()))
	cnt = 0
	for j in range(b):
		cnt += 2**(c[j]-1)
	for j in range(len(valists)):
		x = j|cnt
		valists[x] = min(valists[x], valists[j]+values)
		#print(j, cnt, x, valists)

#print(valists)
ans = valists[2**n-1]
if ans != 10**9:
	print(ans)
else:
	print(-1)