N, M = map(int, input().split()) 
asl = []
for _ in range(M):
    a, b = map(int, input().split()) 
    cl = list(map(int, input().split())) 
    s = 0
    for c in cl:
        s += 1<<(c-1)
    asl.append([a,s])

INF = 10**8
dp = [INF]*(2**N)
dp[0] = 0
for i in range(2**N):
    for as_v in asl:
        a, s = as_v
        dp[i|s] = min(dp[i]+a ,dp[i|s])

ans = dp[2**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 asl = [] asl [] for _ in range(M):
    a, b = map(int, input().split()) 
    cl = list(map(int, input().split())) 
    s = 0
    for c in cl:
        s += 1<<(c-1)
    asl.append([a,s]) _ range(M) range M a, b = map(int, input().split()) a map(int, input().split()) map int input().split() ().split () input split b cl = list(map(int, input().split())) cl list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split s = 0 s 0 for c in cl:
        s += 1<<(c-1)
     c cl s += 1<<(c-1) s 1<<(c-1) 1 c-1 c 1 asl.append([a,s]) asl.append asl append [a,s] a s INF = 10**8 INF 10**8 10 8 dp = [INF]*(2**N) dp [INF]*(2**N) [INF] INF 2**N 2 N dp[0] = 0 dp[0] dp 0 0 for i in range(2**N):
    for as_v in asl:
        a, s = as_v
        dp[i|s] = min(dp[i]+a ,dp[i|s]) i range(2**N) range 2**N 2 N for as_v in asl:
        a, s = as_v
        dp[i|s] = min(dp[i]+a ,dp[i|s]) as_v asl a, s = as_v a as_v s dp[i|s] = min(dp[i]+a ,dp[i|s]) dp[i|s] dp i|s i s min(dp[i]+a ,dp[i|s]) min dp[i]+a dp[i] dp i a dp[i|s] dp i|s i s ans = dp[2**N-1] ans dp[2**N-1] dp 2**N-1 2**N 2 N 1 if ans == INF:
    print(-1)
else:
    print(ans) ans == INF ans INF print(-1) print -1 print(ans) print ans N, M = map(int, input().split()) map(int, input().split()) N s = as_v as_v s ans = dp[2**N-1] dp[2**N-1] ans b = map(int, input().split()) map(int, input().split()) b s += 1<<(c-1) 1<<(c-1) s cl = list(map(int, input().split())) list(map(int, input().split())) cl dp = [INF]*(2**N) [INF]*(2**N) dp a, b = map(int, input().split()) map(int, input().split()) a s = 0 0 s M = map(int, input().split()) map(int, input().split()) M asl = [] [] asl INF = 10**8 10**8 INF a, s = as_v as_v a
N, M = map(int, input().split()) 
asl = []
for _ in range(M):
    a, b = map(int, input().split()) 
    cl = list(map(int, input().split())) 
    s = 0
    for c in cl:
        s += 1<<(c-1)
    asl.append([a,s])

INF = 10**8
dp = [INF]*(2**N)
dp[0] = 0
for i in range(2**N):
    for as_v in asl:
        a, s = as_v
        dp[i|s] = min(dp[i]+a ,dp[i|s])

ans = dp[2**N-1]
if ans == INF:
    print(-1)
else:
    print(ans)
