import sys
import itertools

N,M = map(int, input().split())
AB = []
C = []
for _ in range(M):
    AB.append(tuple(map(int, input().split())))
    C.append(sum(1<<(int(x)-1) for x in map(int, input().split())))

INF = 10**18
dp = [INF]*(1<<N)
dp[0] = 0

for n,((a,b),c) in itertools.product(range(1<<N), zip(AB,C)):
    m = n|c
    x = dp[n] + a
    if dp[m] > x:
        dp[m] = x

ans = dp[-1]
if ans == INF:
    ans = -1
print(ans) import sys sys import itertools itertools N,M = map(int, input().split()) N map(int, input().split()) map int input().split() ().split () input split M AB = [] AB [] C = [] C [] for _ in range(M):
    AB.append(tuple(map(int, input().split())))
    C.append(sum(1<<(int(x)-1) for x in map(int, input().split()))) _ range(M) range M AB.append(tuple(map(int, input().split()))) AB.append AB append tuple(map(int, input().split())) tuple map(int, input().split()) map int input().split() ().split () input split C.append(sum(1<<(int(x)-1) for x in map(int, input().split()))) C.append C append sum(1<<(int(x)-1) for x in map(int, input().split())) sum 1<<(int(x)-1) 1 int(x)-1 int(x) int x 1 INF = 10**18 INF 10**18 10 18 dp = [INF]*(1<<N) dp [INF]*(1<<N) [INF] INF 1<<N 1 N dp[0] = 0 dp[0] dp 0 0 for n,((a,b),c) in itertools.product(range(1<<N), zip(AB,C)):
    m = n|c
    x = dp[n] + a
    if dp[m] > x:
        dp[m] = x n ((a,b),c) (a,b) a b c itertools.product(range(1<<N), zip(AB,C)) itertools.product itertools product range(1<<N) range 1<<N 1 N zip(AB,C) zip AB C m = n|c m n|c n c x = dp[n] + a x dp[n] + a dp[n] dp n a if dp[m] > x:
        dp[m] = x dp[m] > x dp[m] dp m x dp[m] = x dp[m] dp m x ans = dp[-1] ans dp[-1] dp -1 if ans == INF:
    ans = -1 ans == INF ans INF ans = -1 ans -1 print(ans) print ans M = map(int, input().split()) map(int, input().split()) M N,M = map(int, input().split()) map(int, input().split()) N AB = [] [] AB ans = -1 -1 ans m = n|c n|c m x = dp[n] + a dp[n] + a x INF = 10**18 10**18 INF C = [] [] C ans = dp[-1] dp[-1] ans dp = [INF]*(1<<N) [INF]*(1<<N) dp
import sys
import itertools

N,M = map(int, input().split())
AB = []
C = []
for _ in range(M):
    AB.append(tuple(map(int, input().split())))
    C.append(sum(1<<(int(x)-1) for x in map(int, input().split())))

INF = 10**18
dp = [INF]*(1<<N)
dp[0] = 0

for n,((a,b),c) in itertools.product(range(1<<N), zip(AB,C)):
    m = n|c
    x = dp[n] + a
    if dp[m] > x:
        dp[m] = x

ans = dp[-1]
if ans == INF:
    ans = -1
print(ans)