N, M = map(int, input().split())
a,c = [], []
for _ in range(M):
	ta, _ = map(int, input().split())
	tc = 0
	tmp = list(map(int, input().split()))
	for t in tmp:
		tc += 1 << (t-1)

	a.append(ta)
	c.append(tc)

inf = float('inf')

DP = [[inf] * (1 << N) for _ in range(M)]
for i in range(M):
	DP[i][0] = 0
DP[0][c[0]] = a[0]

for i in range(1, M):
	for s in range(1 << N):
		DP[i][s] = min(DP[i][s], DP[i-1][s])
		DP[i][s | c[i]] = min(DP[i][s|c[i]], DP[i-1][s|c[i]], DP[i-1][s]+a[i])

ans = DP[M-1][(1 << N)-1]
if ans == inf:
	print(-1)
else:
	print(ans) N, M = map(int, input().split()) N map(int, input().split()) map int input().split() ().split () input split M a,c = [], [] a [] c [] for _ in range(M):
	ta, _ = map(int, input().split())
	tc = 0
	tmp = list(map(int, input().split()))
	for t in tmp:
		tc += 1 << (t-1)

	a.append(ta)
	c.append(tc) _ range(M) range M ta, _ = map(int, input().split()) ta map(int, input().split()) map int input().split() ().split () input split _ tc = 0 tc 0 tmp = list(map(int, input().split())) tmp list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split for t in tmp:
		tc += 1 << (t-1)

	 t tmp tc += 1 << (t-1) tc 1 << (t-1) 1 t-1 t 1 a.append(ta) a.append a append ta c.append(tc) c.append c append tc inf = float('inf') inf float('inf') float 'inf' [inf] * (1 << N) for _ in range(M) for _ in range(M) _ range(M) range M for _ in range(M) [inf] * (1 << N) [inf] inf 1 << N 1 N DP = [[inf] * (1 << N) for _ in range(M)] DP [[inf] * (1 << N) for _ in range(M)] for i in range(M):
	DP[i][0] = 0 i range(M) range M DP[i][0] = 0 DP[i][0] [i] DP i 0 0 DP[0][c[0]] = a[0] DP[0][c[0]] [0] DP 0 c[0] c 0 a[0] a 0 for i in range(1, M):
	for s in range(1 << N):
		DP[i][s] = min(DP[i][s], DP[i-1][s])
		DP[i][s | c[i]] = min(DP[i][s|c[i]], DP[i-1][s|c[i]], DP[i-1][s]+a[i]) i range(1, M) range 1 M for s in range(1 << N):
		DP[i][s] = min(DP[i][s], DP[i-1][s])
		DP[i][s | c[i]] = min(DP[i][s|c[i]], DP[i-1][s|c[i]], DP[i-1][s]+a[i]) s range(1 << N) range 1 << N 1 N DP[i][s] = min(DP[i][s], DP[i-1][s]) DP[i][s] [i] DP i s min(DP[i][s], DP[i-1][s]) min DP[i][s] [i] DP i s DP[i-1][s] [i-1] DP i-1 i 1 s DP[i][s | c[i]] = min(DP[i][s|c[i]], DP[i-1][s|c[i]], DP[i-1][s]+a[i]) DP[i][s | c[i]] [i] DP i s | c[i] s c[i] c i min(DP[i][s|c[i]], DP[i-1][s|c[i]], DP[i-1][s]+a[i]) min DP[i][s|c[i]] [i] DP i s|c[i] s c[i] c i DP[i-1][s|c[i]] [i-1] DP i-1 i 1 s|c[i] s c[i] c i DP[i-1][s]+a[i] DP[i-1][s] [i-1] DP i-1 i 1 s a[i] a i ans = DP[M-1][(1 << N)-1] ans DP[M-1][(1 << N)-1] [M-1] DP M-1 M 1 (1 << N)-1 1 << N 1 N 1 if ans == inf:
	print(-1)
else:
	print(ans) ans == inf ans inf print(-1) print -1 print(ans) print ans ta, _ = map(int, input().split()) map(int, input().split()) ta inf = float('inf') float('inf') inf a,c = [], [] [] a _ = map(int, input().split()) map(int, input().split()) _ ans = DP[M-1][(1 << N)-1] DP[M-1][(1 << N)-1] ans DP = [[inf] * (1 << N) for _ in range(M)] [[inf] * (1 << N) for _ in range(M)] DP M = map(int, input().split()) map(int, input().split()) M tc = 0 0 tc N, M = map(int, input().split()) map(int, input().split()) N c = [], [] [] c tmp = list(map(int, input().split())) list(map(int, input().split())) tmp tc += 1 << (t-1) 1 << (t-1) tc
N, M = map(int, input().split())
a,c = [], []
for _ in range(M):
	ta, _ = map(int, input().split())
	tc = 0
	tmp = list(map(int, input().split()))
	for t in tmp:
		tc += 1 << (t-1)

	a.append(ta)
	c.append(tc)

inf = float('inf')

DP = [[inf] * (1 << N) for _ in range(M)]
for i in range(M):
	DP[i][0] = 0
DP[0][c[0]] = a[0]

for i in range(1, M):
	for s in range(1 << N):
		DP[i][s] = min(DP[i][s], DP[i-1][s])
		DP[i][s | c[i]] = min(DP[i][s|c[i]], DP[i-1][s|c[i]], DP[i-1][s]+a[i])

ans = DP[M-1][(1 << N)-1]
if ans == inf:
	print(-1)
else:
	print(ans)