n,m = map(int,input().split())
p = []
for k in range(m):  
    a,b = map(int,input().split())
    c = list(map(int,input().split()))
    key = 0
    for i in c:
        key += 2**(i-1)
    p.append([a,key])
inf = 10**9
dp = []
for u in range(m+1):
    dp.append([inf for i in range(2**n)])
dp[0][0] = 0
for i in range(m):
    for k in range(2**n):
        dp[i+1][k] = dp[i][k]
    for k in range(2**n):
        dp[i+1][k|p[i][1]] = min(dp[i][k|p[i][1]],dp[i][k]+p[i][0],dp[i+1][k|p[i][1]])
if dp[-1][-1] == inf:
    print(-1)
else:
    print(dp[-1][-1]) n,m = map(int,input().split()) n map(int,input().split()) map int input().split() ().split () input split m p = [] p [] for k in range(m):  
    a,b = map(int,input().split())
    c = list(map(int,input().split()))
    key = 0
    for i in c:
        key += 2**(i-1)
    p.append([a,key]) k 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 key = 0 key 0 for i in c:
        key += 2**(i-1)
     i c key += 2**(i-1) key 2**(i-1) 2 i-1 i 1 p.append([a,key]) p.append p append [a,key] a key inf = 10**9 inf 10**9 10 9 dp = [] dp [] for u in range(m+1):
    dp.append([inf for i in range(2**n)]) u range(m+1) range m+1 m 1 inf for i in range(2**n) for i in range(2**n) i range(2**n) range 2**n 2 n for i in range(2**n) inf dp.append([inf for i in range(2**n)]) dp.append dp append [inf for i in range(2**n)] dp[0][0] = 0 dp[0][0] [0] dp 0 0 0 for i in range(m):
    for k in range(2**n):
        dp[i+1][k] = dp[i][k]
    for k in range(2**n):
        dp[i+1][k|p[i][1]] = min(dp[i][k|p[i][1]],dp[i][k]+p[i][0],dp[i+1][k|p[i][1]]) i range(m) range m for k in range(2**n):
        dp[i+1][k] = dp[i][k]
     k range(2**n) range 2**n 2 n dp[i+1][k] = dp[i][k] dp[i+1][k] [i+1] dp i+1 i 1 k dp[i][k] [i] dp i k for k in range(2**n):
        dp[i+1][k|p[i][1]] = min(dp[i][k|p[i][1]],dp[i][k]+p[i][0],dp[i+1][k|p[i][1]]) k range(2**n) range 2**n 2 n dp[i+1][k|p[i][1]] = min(dp[i][k|p[i][1]],dp[i][k]+p[i][0],dp[i+1][k|p[i][1]]) dp[i+1][k|p[i][1]] [i+1] dp i+1 i 1 k|p[i][1] k p[i][1] [i] p i 1 min(dp[i][k|p[i][1]],dp[i][k]+p[i][0],dp[i+1][k|p[i][1]]) min dp[i][k|p[i][1]] [i] dp i k|p[i][1] k p[i][1] [i] p i 1 dp[i][k]+p[i][0] dp[i][k] [i] dp i k p[i][0] [i] p i 0 dp[i+1][k|p[i][1]] [i+1] dp i+1 i 1 k|p[i][1] k p[i][1] [i] p i 1 if dp[-1][-1] == inf:
    print(-1)
else:
    print(dp[-1][-1]) dp[-1][-1] == inf dp[-1][-1] [-1] dp -1 -1 inf print(-1) print -1 print(dp[-1][-1]) print dp[-1][-1] [-1] dp -1 -1 b = map(int,input().split()) map(int,input().split()) b a,b = map(int,input().split()) map(int,input().split()) a key += 2**(i-1) 2**(i-1) key n,m = map(int,input().split()) map(int,input().split()) n inf = 10**9 10**9 inf dp = [] [] dp m = map(int,input().split()) map(int,input().split()) m p = [] [] p c = list(map(int,input().split())) list(map(int,input().split())) c key = 0 0 key
n,m = map(int,input().split())
p = []
for k in range(m):  
    a,b = map(int,input().split())
    c = list(map(int,input().split()))
    key = 0
    for i in c:
        key += 2**(i-1)
    p.append([a,key])
inf = 10**9
dp = []
for u in range(m+1):
    dp.append([inf for i in range(2**n)])
dp[0][0] = 0
for i in range(m):
    for k in range(2**n):
        dp[i+1][k] = dp[i][k]
    for k in range(2**n):
        dp[i+1][k|p[i][1]] = min(dp[i][k|p[i][1]],dp[i][k]+p[i][0],dp[i+1][k|p[i][1]])
if dp[-1][-1] == inf:
    print(-1)
else:
    print(dp[-1][-1])