n,m = map(int,input().split())

ab = []
c = []
for _ in range(m):
    ab_i = tuple(map(int,input().split()))
    ab.append(ab_i)
    c_i = tuple(map(int,input().split()))
    c_i_bit = 0
    for j in c_i:
        c_i_bit += 1 << (j-1)
    c.append(c_i_bit)

inf = 10**10
dp = [ [inf] * 2**n for _ in range(m+1) ]
dp[0][0] = 0

for i in range(m):
    for j in range(2**n):
        dp[i+1][j] = min(dp[i+1][j], dp[i][j])
        dp[i+1][j|c[i]] = min(dp[i+1][j|c[i]], dp[i][j] + ab[i][0])

ans = dp[-1][-1]
if(ans == inf):
    print(-1)
else:
    print(ans) n,m = map(int,input().split()) n map(int,input().split()) map int input().split() ().split () input split m ab = [] ab [] c = [] c [] for _ in range(m):
    ab_i = tuple(map(int,input().split()))
    ab.append(ab_i)
    c_i = tuple(map(int,input().split()))
    c_i_bit = 0
    for j in c_i:
        c_i_bit += 1 << (j-1)
    c.append(c_i_bit) _ range(m) range m ab_i = tuple(map(int,input().split())) ab_i tuple(map(int,input().split())) tuple map(int,input().split()) map int input().split() ().split () input split ab.append(ab_i) ab.append ab append ab_i c_i = tuple(map(int,input().split())) c_i tuple(map(int,input().split())) tuple map(int,input().split()) map int input().split() ().split () input split c_i_bit = 0 c_i_bit 0 for j in c_i:
        c_i_bit += 1 << (j-1)
     j c_i c_i_bit += 1 << (j-1) c_i_bit 1 << (j-1) 1 j-1 j 1 c.append(c_i_bit) c.append c append c_i_bit inf = 10**10 inf 10**10 10 10 [inf] * 2**n for _ in range(m+1) for _ in range(m+1) _ range(m+1) range m+1 m 1 for _ in range(m+1) [inf] * 2**n [inf] inf 2**n 2 n dp = [ [inf] * 2**n for _ in range(m+1) ] dp [ [inf] * 2**n for _ in range(m+1) ] dp[0][0] = 0 dp[0][0] [0] dp 0 0 0 for i in range(m):
    for j in range(2**n):
        dp[i+1][j] = min(dp[i+1][j], dp[i][j])
        dp[i+1][j|c[i]] = min(dp[i+1][j|c[i]], dp[i][j] + ab[i][0]) i range(m) range m for j in range(2**n):
        dp[i+1][j] = min(dp[i+1][j], dp[i][j])
        dp[i+1][j|c[i]] = min(dp[i+1][j|c[i]], dp[i][j] + ab[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+1][j|c[i]] = min(dp[i+1][j|c[i]], dp[i][j] + ab[i][0]) dp[i+1][j|c[i]] [i+1] dp i+1 i 1 j|c[i] j c[i] c i min(dp[i+1][j|c[i]], dp[i][j] + ab[i][0]) min dp[i+1][j|c[i]] [i+1] dp i+1 i 1 j|c[i] j c[i] c i dp[i][j] + ab[i][0] dp[i][j] [i] dp i j ab[i][0] [i] ab i 0 ans = dp[-1][-1] ans dp[-1][-1] [-1] dp -1 -1 if(ans == inf):
    print(-1)
else:
    print(ans) ans == inf ans inf print(-1) print -1 print(ans) print ans ab = [] [] ab c_i_bit += 1 << (j-1) 1 << (j-1) c_i_bit dp = [ [inf] * 2**n for _ in range(m+1) ] [ [inf] * 2**n for _ in range(m+1) ] dp ans = dp[-1][-1] dp[-1][-1] ans n,m = map(int,input().split()) map(int,input().split()) n m = map(int,input().split()) map(int,input().split()) m c_i_bit = 0 0 c_i_bit ab_i = tuple(map(int,input().split())) tuple(map(int,input().split())) ab_i inf = 10**10 10**10 inf c = [] [] c c_i = tuple(map(int,input().split())) tuple(map(int,input().split())) c_i
n,m = map(int,input().split())

ab = []
c = []
for _ in range(m):
    ab_i = tuple(map(int,input().split()))
    ab.append(ab_i)
    c_i = tuple(map(int,input().split()))
    c_i_bit = 0
    for j in c_i:
        c_i_bit += 1 << (j-1)
    c.append(c_i_bit)

inf = 10**10
dp = [ [inf] * 2**n for _ in range(m+1) ]
dp[0][0] = 0

for i in range(m):
    for j in range(2**n):
        dp[i+1][j] = min(dp[i+1][j], dp[i][j])
        dp[i+1][j|c[i]] = min(dp[i+1][j|c[i]], dp[i][j] + ab[i][0])

ans = dp[-1][-1]
if(ans == inf):
    print(-1)
else:
    print(ans)