INF = 10**9

N, M = map(int, input().split())
key = [[]]
for i in range(M):
    a, b = map(int, input().split())
    C = list(map(int, input().split()))
    tmp = 0
    for c in C:
        tmp += 2**(c-1)
    key.append([a, tmp])

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

N, M = map(int, input().split())
key = [[]]
for i in range(M):
    a, b = map(int, input().split())
    C = list(map(int, input().split()))
    tmp = 0
    for c in C:
        tmp += 2**(c-1)
    key.append([a, tmp])

dp = [[INF for _ in range(2**N)] for _ in range(M+2)]
for i in range(1, M+1):
    dp[i][key[i][1]] = min(dp[i][key[i][1]], key[i][0])
    for j in range(2**N):
        dp[i+1][j] = min(dp[i+1][j], dp[i][j])
        dp[i][j|key[i][1]] = min(dp[i][j|key[i][1]], dp[i-1][j]+key[i][0])
if dp[M][2**N-1] == INF:
    print(-1)
else:
    print(dp[M][2**N-1])