n,m = map(int,input().split())
dp = []
key = []
for i in range(m):
    d = [10**15]*(2**n)
    d[0] = 0
    dp.append(d)
for i in range(m):
    cost,num = map(int,input().split())
    if num == 1:
        t = int(input())
        key.append([cost,2**(t-1)])
    else:
        p = list(map(int,input().split()))
        cur = 0
        for i in range(len(p)):
            cur += 2**(p[i]-1)
        key.append([cost,cur])
for i in range(m):
    for j in range(2**n):
        if i != 0:
            dp[i][j] = min(dp[i][j],dp[i-1][j])
        dp[i][j|key[i][1]] = min(dp[i][j|key[i][1]],dp[i][j]+key[i][0])
if dp[m-1][2**n-1] != 10**15:
    print(dp[m-1][2**n-1])
else:
    print(-1) n,m = map(int,input().split()) n map(int,input().split()) map int input().split() ().split () input split m dp = [] dp [] key = [] key [] for i in range(m):
    d = [10**15]*(2**n)
    d[0] = 0
    dp.append(d) i range(m) range m d = [10**15]*(2**n) d [10**15]*(2**n) [10**15] 10**15 10 15 2**n 2 n d[0] = 0 d[0] d 0 0 dp.append(d) dp.append dp append d for i in range(m):
    cost,num = map(int,input().split())
    if num == 1:
        t = int(input())
        key.append([cost,2**(t-1)])
    else:
        p = list(map(int,input().split()))
        cur = 0
        for i in range(len(p)):
            cur += 2**(p[i]-1)
        key.append([cost,cur]) i range(m) range m cost,num = map(int,input().split()) cost map(int,input().split()) map int input().split() ().split () input split num if num == 1:
        t = int(input())
        key.append([cost,2**(t-1)])
    else:
        p = list(map(int,input().split()))
        cur = 0
        for i in range(len(p)):
            cur += 2**(p[i]-1)
        key.append([cost,cur]) num == 1 num 1 t = int(input()) t int(input()) int input() input key.append([cost,2**(t-1)]) key.append key append [cost,2**(t-1)] cost 2**(t-1) 2 t-1 t 1 p = list(map(int,input().split())) p list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split cur = 0 cur 0 for i in range(len(p)):
            cur += 2**(p[i]-1)
         i range(len(p)) range len(p) len p cur += 2**(p[i]-1) cur 2**(p[i]-1) 2 p[i]-1 p[i] p i 1 key.append([cost,cur]) key.append key append [cost,cur] cost cur for i in range(m):
    for j in range(2**n):
        if i != 0:
            dp[i][j] = min(dp[i][j],dp[i-1][j])
        dp[i][j|key[i][1]] = min(dp[i][j|key[i][1]],dp[i][j]+key[i][0]) i range(m) range m for j in range(2**n):
        if i != 0:
            dp[i][j] = min(dp[i][j],dp[i-1][j])
        dp[i][j|key[i][1]] = min(dp[i][j|key[i][1]],dp[i][j]+key[i][0]) j range(2**n) range 2**n 2 n if i != 0:
            dp[i][j] = min(dp[i][j],dp[i-1][j])
         i != 0 i 0 dp[i][j] = min(dp[i][j],dp[i-1][j]) dp[i][j] [i] dp i j min(dp[i][j],dp[i-1][j]) min dp[i][j] [i] dp i j dp[i-1][j] [i-1] dp i-1 i 1 j dp[i][j|key[i][1]] = min(dp[i][j|key[i][1]],dp[i][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][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][j]+key[i][0] dp[i][j] [i] dp i j key[i][0] [i] key i 0 if dp[m-1][2**n-1] != 10**15:
    print(dp[m-1][2**n-1])
else:
    print(-1) dp[m-1][2**n-1] != 10**15 dp[m-1][2**n-1] [m-1] dp m-1 m 1 2**n-1 2**n 2 n 1 10**15 10 15 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 print(-1) print -1 d = [10**15]*(2**n) [10**15]*(2**n) d key = [] [] key n,m = map(int,input().split()) map(int,input().split()) n m = map(int,input().split()) map(int,input().split()) m cur = 0 0 cur cur += 2**(p[i]-1) 2**(p[i]-1) cur num = map(int,input().split()) map(int,input().split()) num dp = [] [] dp cost,num = map(int,input().split()) map(int,input().split()) cost t = int(input()) int(input()) t p = list(map(int,input().split())) list(map(int,input().split())) p
n,m = map(int,input().split())
dp = []
key = []
for i in range(m):
    d = [10**15]*(2**n)
    d[0] = 0
    dp.append(d)
for i in range(m):
    cost,num = map(int,input().split())
    if num == 1:
        t = int(input())
        key.append([cost,2**(t-1)])
    else:
        p = list(map(int,input().split()))
        cur = 0
        for i in range(len(p)):
            cur += 2**(p[i]-1)
        key.append([cost,cur])
for i in range(m):
    for j in range(2**n):
        if i != 0:
            dp[i][j] = min(dp[i][j],dp[i-1][j])
        dp[i][j|key[i][1]] = min(dp[i][j|key[i][1]],dp[i][j]+key[i][0])
if dp[m-1][2**n-1] != 10**15:
    print(dp[m-1][2**n-1])
else:
    print(-1)
