n,m = map(int,input().split())
ab = []
c = []
for i in range(m):
    ab.append(list(map(int,input().split())))
    s = 0
    for j in map(int,input().split()):
        s += 2**(j-1)
        
    c.append(s)

dp = [[float("INF")]*(2**n) for i in range(m+1)]

dp[0][0] = 0

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

if dp[-1][-1] == float("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 ab = [] ab [] c = [] c [] for i in range(m):
    ab.append(list(map(int,input().split())))
    s = 0
    for j in map(int,input().split()):
        s += 2**(j-1)
        
    c.append(s) i range(m) range m ab.append(list(map(int,input().split()))) ab.append ab append list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split s = 0 s 0 for j in map(int,input().split()):
        s += 2**(j-1)
        
     j map(int,input().split()) map int input().split() ().split () input split s += 2**(j-1) s 2**(j-1) 2 j-1 j 1 c.append(s) c.append c append s [float("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) [float("INF")]*(2**n) [float("INF")] float("INF") float "INF" 2**n 2 n dp = [[float("INF")]*(2**n) for i in range(m+1)] dp [[float("INF")]*(2**n) for i 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):
        if dp[i][j] != float("INF"):
            dp[i+1][j] = min(dp[i+1][j],dp[i][j])
            x = j|c[i]
            dp[i+1][x] = min(dp[i+1][x],dp[i][j]+ab[i][0]) i range(m) range m for j in range(2**n):
        if dp[i][j] != float("INF"):
            dp[i+1][j] = min(dp[i+1][j],dp[i][j])
            x = j|c[i]
            dp[i+1][x] = min(dp[i+1][x],dp[i][j]+ab[i][0]) j range(2**n) range 2**n 2 n if dp[i][j] != float("INF"):
            dp[i+1][j] = min(dp[i+1][j],dp[i][j])
            x = j|c[i]
            dp[i+1][x] = min(dp[i+1][x],dp[i][j]+ab[i][0]) dp[i][j] != float("INF") dp[i][j] [i] dp i j float("INF") float "INF" 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 x = j|c[i] x j|c[i] j c[i] c i dp[i+1][x] = min(dp[i+1][x],dp[i][j]+ab[i][0]) dp[i+1][x] [i+1] dp i+1 i 1 x min(dp[i+1][x],dp[i][j]+ab[i][0]) min dp[i+1][x] [i+1] dp i+1 i 1 x dp[i][j]+ab[i][0] dp[i][j] [i] dp i j ab[i][0] [i] ab i 0 if dp[-1][-1] == float("INF"):
    print(-1)
else:
    print(dp[-1][-1]) dp[-1][-1] == float("INF") dp[-1][-1] [-1] dp -1 -1 float("INF") float "INF" print(-1) print -1 print(dp[-1][-1]) print dp[-1][-1] [-1] dp -1 -1 dp = [[float("INF")]*(2**n) for i in range(m+1)] [[float("INF")]*(2**n) for i in range(m+1)] dp m = map(int,input().split()) map(int,input().split()) m ab = [] [] ab x = j|c[i] j|c[i] x c = [] [] c n,m = map(int,input().split()) map(int,input().split()) n s += 2**(j-1) 2**(j-1) s s = 0 0 s
n,m = map(int,input().split())
ab = []
c = []
for i in range(m):
    ab.append(list(map(int,input().split())))
    s = 0
    for j in map(int,input().split()):
        s += 2**(j-1)
        
    c.append(s)

dp = [[float("INF")]*(2**n) for i in range(m+1)]

dp[0][0] = 0

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

if dp[-1][-1] == float("INF"):
    print(-1)
else:
    print(dp[-1][-1])

