INF = float("INF")
n,m = map(int,input().split())
A = [0]*m
C = [0]*m
for i in range(m):
    a,b = map(int,input().split())
    A[i] = a
    for j in map(int,input().split()):
        j -= 1
        C[i] += 1<<j 

dp = [[INF]*(m+1) for _ in range(1<<n)]
dp[0][0] = 0
for i in range(1<<n):
    for j in range(m):
        dp[i][j+1] = min(dp[i][j],dp[C[j]&i^i][j] + A[j])

# for i in range(1<<n): print(dp[i])
print(dp[-1][-1] if dp[-1][-1] != INF else -1) INF = float("INF") INF float("INF") float "INF" n,m = map(int,input().split()) n map(int,input().split()) map int input().split() ().split () input split m A = [0]*m A [0]*m [0] 0 m C = [0]*m C [0]*m [0] 0 m for i in range(m):
    a,b = map(int,input().split())
    A[i] = a
    for j in map(int,input().split()):
        j -= 1
        C[i] += 1<<j  i range(m) range m a,b = map(int,input().split()) a map(int,input().split()) map int input().split() ().split () input split b A[i] = a A[i] A i a for j in map(int,input().split()):
        j -= 1
        C[i] += 1<<j  j map(int,input().split()) map int input().split() ().split () input split j -= 1 j 1 C[i] += 1<<j C[i] C i 1<<j 1 j [INF]*(m+1) for _ in range(1<<n) for _ in range(1<<n) _ range(1<<n) range 1<<n 1 n for _ in range(1<<n) [INF]*(m+1) [INF] INF m+1 m 1 dp = [[INF]*(m+1) for _ in range(1<<n)] dp [[INF]*(m+1) for _ in range(1<<n)] dp[0][0] = 0 dp[0][0] [0] dp 0 0 0 for i in range(1<<n):
    for j in range(m):
        dp[i][j+1] = min(dp[i][j],dp[C[j]&i^i][j] + A[j])

# for i in range(1<<n): print(dp[i]) i range(1<<n) range 1<<n 1 n for j in range(m):
        dp[i][j+1] = min(dp[i][j],dp[C[j]&i^i][j] + A[j])

# for i in range(1<<n): print(dp[i]) j range(m) range m dp[i][j+1] = min(dp[i][j],dp[C[j]&i^i][j] + A[j]) dp[i][j+1] [i] dp i j+1 j 1 min(dp[i][j],dp[C[j]&i^i][j] + A[j]) min dp[i][j] [i] dp i j dp[C[j]&i^i][j] + A[j] dp[C[j]&i^i][j] [C[j]&i^i] dp C[j]&i^i C[j]&i C[j] C j i i j A[j] A j print(dp[-1][-1] if dp[-1][-1] != INF else -1) print dp[-1][-1] if dp[-1][-1] != INF else -1 dp[-1][-1] != INF dp[-1][-1] [-1] dp -1 -1 INF dp[-1][-1] [-1] dp -1 -1 -1 INF = float("INF") float("INF") INF m = map(int,input().split()) map(int,input().split()) m a,b = map(int,input().split()) map(int,input().split()) a dp = [[INF]*(m+1) for _ in range(1<<n)] [[INF]*(m+1) for _ in range(1<<n)] dp j -= 1 1 j A = [0]*m [0]*m A C = [0]*m [0]*m C n,m = map(int,input().split()) map(int,input().split()) n b = map(int,input().split()) map(int,input().split()) b
INF = float("INF")
n,m = map(int,input().split())
A = [0]*m
C = [0]*m
for i in range(m):
    a,b = map(int,input().split())
    A[i] = a
    for j in map(int,input().split()):
        j -= 1
        C[i] += 1<<j 

dp = [[INF]*(m+1) for _ in range(1<<n)]
dp[0][0] = 0
for i in range(1<<n):
    for j in range(m):
        dp[i][j+1] = min(dp[i][j],dp[C[j]&i^i][j] + A[j])

# for i in range(1<<n): print(dp[i])
print(dp[-1][-1] if dp[-1][-1] != INF else -1)