n, m = map(int, input().split())
A = [0]*m
C = [0]*m
for i in range(m):
    a, b = map(int, input().split())
    A[i] = a
    c = list(map(int, input().split()))
    c = [x-1 for x in c]
    C[i] = c


dp = [10**18]*(2**n)
dp[0] = 0
C_bit = [0]*m
for i in range(m):
    C_bit[i] = 0
    for j in C[i]:
        C_bit[i] += 2**j

for i in range(2**n):
    for j in range(m):
        ni = i | C_bit[j]
        dp[ni] = min(dp[ni], dp[i]+A[j])

if dp[-1] == 10**18:
    print(-1)
else:
    print(dp[-1]) n, m = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split m A = [0]*m A [0]*m [0] 0 m C = [0]*m C [0]*m [0] 0 m for i in range(m):
    a, b = map(int, input().split())
    A[i] = a
    c = list(map(int, input().split()))
    c = [x-1 for x in c]
    C[i] = c i range(m) range m a, b = map(int, input().split()) a map(int, input().split()) map int input().split() ().split () input split b A[i] = a A[i] A i a c = list(map(int, input().split())) c list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split x-1 for x in c for x in c x c for x in c x-1 x 1 c = [x-1 for x in c] c [x-1 for x in c] C[i] = c C[i] C i c dp = [10**18]*(2**n) dp [10**18]*(2**n) [10**18] 10**18 10 18 2**n 2 n dp[0] = 0 dp[0] dp 0 0 C_bit = [0]*m C_bit [0]*m [0] 0 m for i in range(m):
    C_bit[i] = 0
    for j in C[i]:
        C_bit[i] += 2**j i range(m) range m C_bit[i] = 0 C_bit[i] C_bit i 0 for j in C[i]:
        C_bit[i] += 2**j j C[i] C i C_bit[i] += 2**j C_bit[i] C_bit i 2**j 2 j for i in range(2**n):
    for j in range(m):
        ni = i | C_bit[j]
        dp[ni] = min(dp[ni], dp[i]+A[j]) i range(2**n) range 2**n 2 n for j in range(m):
        ni = i | C_bit[j]
        dp[ni] = min(dp[ni], dp[i]+A[j]) j range(m) range m ni = i | C_bit[j] ni i | C_bit[j] i C_bit[j] C_bit j dp[ni] = min(dp[ni], dp[i]+A[j]) dp[ni] dp ni min(dp[ni], dp[i]+A[j]) min dp[ni] dp ni dp[i]+A[j] dp[i] dp i A[j] A j if dp[-1] == 10**18:
    print(-1)
else:
    print(dp[-1]) dp[-1] == 10**18 dp[-1] dp -1 10**18 10 18 print(-1) print -1 print(dp[-1]) print dp[-1] dp -1 c = [x-1 for x in c] [x-1 for x in c] c C_bit = [0]*m [0]*m C_bit b = map(int, input().split()) map(int, input().split()) b a, b = map(int, input().split()) map(int, input().split()) a n, m = map(int, input().split()) map(int, input().split()) n C = [0]*m [0]*m C dp = [10**18]*(2**n) [10**18]*(2**n) dp m = map(int, input().split()) map(int, input().split()) m A = [0]*m [0]*m A c = list(map(int, input().split())) list(map(int, input().split())) c ni = i | C_bit[j] i | C_bit[j] ni
n, m = map(int, input().split())
A = [0]*m
C = [0]*m
for i in range(m):
    a, b = map(int, input().split())
    A[i] = a
    c = list(map(int, input().split()))
    c = [x-1 for x in c]
    C[i] = c


dp = [10**18]*(2**n)
dp[0] = 0
C_bit = [0]*m
for i in range(m):
    C_bit[i] = 0
    for j in C[i]:
        C_bit[i] += 2**j

for i in range(2**n):
    for j in range(m):
        ni = i | C_bit[j]
        dp[ni] = min(dp[ni], dp[i]+A[j])

if dp[-1] == 10**18:
    print(-1)
else:
    print(dp[-1])