n,m = map(int, input().split())
# abl = []
# cl = []

dp = [ [10**9]*(2**n) for _ in range(m+1) ]
dp[0][0] = 0
for i in range(m):
    a,b = map(int, input().split())
    cl = list(map(int, input().split()))
    cbit = 0
    for c in cl:
        cbit += 2**(c-1)
    
    for j in range(2**n):
        if dp[i][j] == 10**9:
            continue
        dp[i+1][j] = min(dp[i][j], dp[i+1][j])
        dp[i+1][j|cbit] = min(dp[i][j]+a, dp[i][j|cbit], dp[i+1][j|cbit])

ans = dp[m][2**n-1]
if ans >= 10**9:
    ans = -1

print(ans) n,m = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split m [10**9]*(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) [10**9]*(2**n) [10**9] 10**9 10 9 2**n 2 n dp = [ [10**9]*(2**n) for _ in range(m+1) ] dp [ [10**9]*(2**n) for _ in range(m+1) ] dp[0][0] = 0 dp[0][0] [0] dp 0 0 0 for i in range(m):
    a,b = map(int, input().split())
    cl = list(map(int, input().split()))
    cbit = 0
    for c in cl:
        cbit += 2**(c-1)
    
    for j in range(2**n):
        if dp[i][j] == 10**9:
            continue
        dp[i+1][j] = min(dp[i][j], dp[i+1][j])
        dp[i+1][j|cbit] = min(dp[i][j]+a, dp[i][j|cbit], dp[i+1][j|cbit]) i range(m) range m a,b = map(int, input().split()) a map(int, input().split()) map int input().split() ().split () input split b cl = list(map(int, input().split())) cl list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split cbit = 0 cbit 0 for c in cl:
        cbit += 2**(c-1)
    
     c cl cbit += 2**(c-1) cbit 2**(c-1) 2 c-1 c 1 for j in range(2**n):
        if dp[i][j] == 10**9:
            continue
        dp[i+1][j] = min(dp[i][j], dp[i+1][j])
        dp[i+1][j|cbit] = min(dp[i][j]+a, dp[i][j|cbit], dp[i+1][j|cbit]) j range(2**n) range 2**n 2 n if dp[i][j] == 10**9:
            continue
         dp[i][j] == 10**9 dp[i][j] [i] dp i j 10**9 10 9 continue dp[i+1][j] = min(dp[i][j], dp[i+1][j]) dp[i+1][j] [i+1] dp i+1 i 1 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+1][j|cbit] = min(dp[i][j]+a, dp[i][j|cbit], dp[i+1][j|cbit]) dp[i+1][j|cbit] [i+1] dp i+1 i 1 j|cbit j cbit min(dp[i][j]+a, dp[i][j|cbit], dp[i+1][j|cbit]) min dp[i][j]+a dp[i][j] [i] dp i j a dp[i][j|cbit] [i] dp i j|cbit j cbit dp[i+1][j|cbit] [i+1] dp i+1 i 1 j|cbit j cbit ans = dp[m][2**n-1] ans dp[m][2**n-1] [m] dp m 2**n-1 2**n 2 n 1 if ans >= 10**9:
    ans = -1 ans >= 10**9 ans 10**9 10 9 ans = -1 ans -1 print(ans) print ans dp = [ [10**9]*(2**n) for _ in range(m+1) ] [ [10**9]*(2**n) for _ in range(m+1) ] dp n,m = map(int, input().split()) map(int, input().split()) n ans = -1 -1 ans m = map(int, input().split()) map(int, input().split()) m cl = list(map(int, input().split())) list(map(int, input().split())) cl cbit = 0 0 cbit cbit += 2**(c-1) 2**(c-1) cbit ans = dp[m][2**n-1] dp[m][2**n-1] ans 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())
# abl = []
# cl = []

dp = [ [10**9]*(2**n) for _ in range(m+1) ]
dp[0][0] = 0
for i in range(m):
    a,b = map(int, input().split())
    cl = list(map(int, input().split()))
    cbit = 0
    for c in cl:
        cbit += 2**(c-1)
    
    for j in range(2**n):
        if dp[i][j] == 10**9:
            continue
        dp[i+1][j] = min(dp[i][j], dp[i+1][j])
        dp[i+1][j|cbit] = min(dp[i][j]+a, dp[i][j|cbit], dp[i+1][j|cbit])

ans = dp[m][2**n-1]
if ans >= 10**9:
    ans = -1

print(ans)