def open(box, key):
    return (box & (2**N-1 - key))
N, M = map(int, input().split())
INF = 10**8+1
dp = [[INF]*2**N for i in range(M+1)]
for i in range(M+1):
    dp[i][0] = 0
key = []
for i in range(M):
    a, b= map(int, input().split())
    n = 0
    c = list(map(int, input().split()))
    for i in range(b):
        n += 2**(c[i]-1)
    key.append((a,n))
for i in range(1,M+1):
    for j in range(2**N):
        dp[i][j] = min(dp[i-1][j], dp[i-1][open(j, key[i-1][1])]+key[i-1][0])
if dp[M-1][2**N-1] == INF:
    dp[M-1][2**N-1] = -1
print(dp[M-1][2**N-1]) def open(box, key):
    return (box & (2**N-1 - key)) open return (box & (2**N-1 - key)) box & (2**N-1 - key) box 2**N-1 - key 2**N-1 2**N 2 N 1 key box box key key N, M = map(int, input().split()) N map(int, input().split()) map int input().split() ().split () input split M INF = 10**8+1 INF 10**8+1 10**8 10 8 1 [INF]*2**N for i in range(M+1) for i in range(M+1) i range(M+1) range M+1 M 1 for i in range(M+1) [INF]*2**N [INF] INF 2**N 2 N dp = [[INF]*2**N for i in range(M+1)] dp [[INF]*2**N for i in range(M+1)] for i in range(M+1):
    dp[i][0] = 0 i range(M+1) range M+1 M 1 dp[i][0] = 0 dp[i][0] [i] dp i 0 0 key = [] key [] for i in range(M):
    a, b= map(int, input().split())
    n = 0
    c = list(map(int, input().split()))
    for i in range(b):
        n += 2**(c[i]-1)
    key.append((a,n)) i range(M) range M a, b= map(int, input().split()) a map(int, input().split()) map int input().split() ().split () input split b n = 0 n 0 c = list(map(int, input().split())) c list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split for i in range(b):
        n += 2**(c[i]-1)
     i range(b) range b n += 2**(c[i]-1) n 2**(c[i]-1) 2 c[i]-1 c[i] c i 1 key.append((a,n)) key.append key append (a,n) a n for i in range(1,M+1):
    for j in range(2**N):
        dp[i][j] = min(dp[i-1][j], dp[i-1][open(j, key[i-1][1])]+key[i-1][0]) i range(1,M+1) range 1 M+1 M 1 for j in range(2**N):
        dp[i][j] = min(dp[i-1][j], dp[i-1][open(j, key[i-1][1])]+key[i-1][0]) j range(2**N) range 2**N 2 N dp[i][j] = min(dp[i-1][j], dp[i-1][open(j, key[i-1][1])]+key[i-1][0]) dp[i][j] [i] dp i j min(dp[i-1][j], dp[i-1][open(j, key[i-1][1])]+key[i-1][0]) min dp[i-1][j] [i-1] dp i-1 i 1 j dp[i-1][open(j, key[i-1][1])]+key[i-1][0] dp[i-1][open(j, key[i-1][1])] [i-1] dp i-1 i 1 open(j, key[i-1][1]) open j key[i-1][1] [i-1] key i-1 i 1 1 key[i-1][0] [i-1] key i-1 i 1 0 if dp[M-1][2**N-1] == INF:
    dp[M-1][2**N-1] = -1 dp[M-1][2**N-1] == INF dp[M-1][2**N-1] [M-1] dp M-1 M 1 2**N-1 2**N 2 N 1 INF dp[M-1][2**N-1] = -1 dp[M-1][2**N-1] [M-1] dp M-1 M 1 2**N-1 2**N 2 N 1 -1 print(dp[M-1][2**N-1]) print dp[M-1][2**N-1] [M-1] dp M-1 M 1 2**N-1 2**N 2 N 1 INF = 10**8+1 10**8+1 INF n = 0 0 n N, M = map(int, input().split()) map(int, input().split()) N M = map(int, input().split()) map(int, input().split()) M a, b= map(int, input().split()) map(int, input().split()) a dp = [[INF]*2**N for i in range(M+1)] [[INF]*2**N for i in range(M+1)] dp b= map(int, input().split()) map(int, input().split()) b c = list(map(int, input().split())) list(map(int, input().split())) c n += 2**(c[i]-1) 2**(c[i]-1) n def open(box, key):
    return (box & (2**N-1 - key)) def open(box, key):
    return (box & (2**N-1 - key)) open key = [] [] key
def open(box, key):
    return (box & (2**N-1 - key))
N, M = map(int, input().split())
INF = 10**8+1
dp = [[INF]*2**N for i in range(M+1)]
for i in range(M+1):
    dp[i][0] = 0
key = []
for i in range(M):
    a, b= map(int, input().split())
    n = 0
    c = list(map(int, input().split()))
    for i in range(b):
        n += 2**(c[i]-1)
    key.append((a,n))
for i in range(1,M+1):
    for j in range(2**N):
        dp[i][j] = min(dp[i-1][j], dp[i-1][open(j, key[i-1][1])]+key[i-1][0])
if dp[M-1][2**N-1] == INF:
    dp[M-1][2**N-1] = -1
print(dp[M-1][2**N-1])