INF = 10**18

N, M = map(int,input().split())

A = []
B = []
C = []

for _ in range(M):
    a, b = map(int,input().split())
    A.append(a)
    B.append(b)
    c = tuple(map(int,input().split()))
    C.append(c)
    
dp = [[INF for j in range(2**N)] for i in range(M + 1)]
dp[0][0] = 0

for i in range(M):
    s = 0
    for k in range(B[i]):
        s += 2**(C[i][k] - 1)
    for j in range(2**N):
        dp[i + 1][j] = min(dp[i + 1][j], dp[i][j])
        dp[i + 1][j | s] = min(dp[i + 1][j | s], dp[i][j] + A[i])
        
res = dp[M][2**N - 1]

print(res if res != INF else -1) INF = 10**18 INF 10**18 10 18 N, M = map(int,input().split()) N map(int,input().split()) map int input().split() ().split () input split M A = [] A [] B = [] B [] C = [] C [] for _ in range(M):
    a, b = map(int,input().split())
    A.append(a)
    B.append(b)
    c = tuple(map(int,input().split()))
    C.append(c)
     _ range(M) range M a, b = map(int,input().split()) a map(int,input().split()) map int input().split() ().split () input split b A.append(a) A.append A append a B.append(b) B.append B append b c = tuple(map(int,input().split())) c tuple(map(int,input().split())) tuple map(int,input().split()) map int input().split() ().split () input split C.append(c) C.append C append c [INF for j in range(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) [INF for j in range(2**N)] dp = [[INF for j in range(2**N)] for i in range(M + 1)] dp [[INF for j in range(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):
    s = 0
    for k in range(B[i]):
        s += 2**(C[i][k] - 1)
    for j in range(2**N):
        dp[i + 1][j] = min(dp[i + 1][j], dp[i][j])
        dp[i + 1][j | s] = min(dp[i + 1][j | s], dp[i][j] + A[i])
         i range(M) range M s = 0 s 0 for k in range(B[i]):
        s += 2**(C[i][k] - 1)
     k range(B[i]) range B[i] B i s += 2**(C[i][k] - 1) s 2**(C[i][k] - 1) 2 C[i][k] - 1 C[i][k] [i] C i k 1 for j in range(2**N):
        dp[i + 1][j] = min(dp[i + 1][j], dp[i][j])
        dp[i + 1][j | s] = min(dp[i + 1][j | s], dp[i][j] + A[i])
         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 | s] = min(dp[i + 1][j | s], dp[i][j] + A[i]) dp[i + 1][j | s] [i + 1] dp i + 1 i 1 j | s j s min(dp[i + 1][j | s], dp[i][j] + A[i]) min dp[i + 1][j | s] [i + 1] dp i + 1 i 1 j | s j s dp[i][j] + A[i] dp[i][j] [i] dp i j A[i] A i res = dp[M][2**N - 1] res dp[M][2**N - 1] [M] dp M 2**N - 1 2**N 2 N 1 print(res if res != INF else -1) print res if res != INF else -1 res != INF res INF res -1 s = 0 0 s A = [] [] A N, M = map(int,input().split()) map(int,input().split()) N a, b = map(int,input().split()) map(int,input().split()) a M = map(int,input().split()) map(int,input().split()) M s += 2**(C[i][k] - 1) 2**(C[i][k] - 1) s C = [] [] C b = map(int,input().split()) map(int,input().split()) b res = dp[M][2**N - 1] dp[M][2**N - 1] res B = [] [] B c = tuple(map(int,input().split())) tuple(map(int,input().split())) c INF = 10**18 10**18 INF dp = [[INF for j in range(2**N)] for i in range(M + 1)] [[INF for j in range(2**N)] for i in range(M + 1)] dp
INF = 10**18

N, M = map(int,input().split())

A = []
B = []
C = []

for _ in range(M):
    a, b = map(int,input().split())
    A.append(a)
    B.append(b)
    c = tuple(map(int,input().split()))
    C.append(c)
    
dp = [[INF for j in range(2**N)] for i in range(M + 1)]
dp[0][0] = 0

for i in range(M):
    s = 0
    for k in range(B[i]):
        s += 2**(C[i][k] - 1)
    for j in range(2**N):
        dp[i + 1][j] = min(dp[i + 1][j], dp[i][j])
        dp[i + 1][j | s] = min(dp[i + 1][j | s], dp[i][j] + A[i])
        
res = dp[M][2**N - 1]

print(res if res != INF else -1)