N, M = map(int, input().split())
Cost = []
for i in range(M):
    a, b = map(int, input().split())
    c = 0
    K = list(map(int, input().split()))
    for j in range(b):
        c += 2**(K[j]-1)
    Cost.append([c, a])

dp = [[float("inf")]*(2**N+1) for _ in range(M+1)]
for i in range(M+1):
    dp[i][0] = 0

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

if dp[M][2**N-1] == float("inf"):
    print(-1)
else:
    print(dp[M][2**N-1]) N, M = map(int, input().split()) N map(int, input().split()) map int input().split() ().split () input split M Cost = [] Cost [] for i in range(M):
    a, b = map(int, input().split())
    c = 0
    K = list(map(int, input().split()))
    for j in range(b):
        c += 2**(K[j]-1)
    Cost.append([c, a]) i range(M) range M a, b = map(int, input().split()) a map(int, input().split()) map int input().split() ().split () input split b c = 0 c 0 K = list(map(int, input().split())) K list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split for j in range(b):
        c += 2**(K[j]-1)
     j range(b) range b c += 2**(K[j]-1) c 2**(K[j]-1) 2 K[j]-1 K[j] K j 1 Cost.append([c, a]) Cost.append Cost append [c, a] c a [float("inf")]*(2**N+1) for _ in range(M+1) for _ in range(M+1) _ range(M+1) range M+1 M 1 for _ in range(M+1) [float("inf")]*(2**N+1) [float("inf")] float("inf") float "inf" 2**N+1 2**N 2 N 1 dp = [[float("inf")]*(2**N+1) for _ in range(M+1)] dp [[float("inf")]*(2**N+1) for _ in range(M+1)] for i in range(M+1):
    dp[i][0] = 0 i range(M+1) range M+1 M 1 dp[i][0] = 0 dp[i][0] [i] dp i 0 0 for i in range(1, M+1):
    for j in range(2**N):
        k = Cost[i-1][0] | j
        dp[i][j] = min(dp[i-1][j], dp[i][j])
        dp[i][k] = min([dp[i-1][j] + Cost[i-1][1], dp[i-1][k], dp[i][k]]) i range(1, M+1) range 1 M+1 M 1 for j in range(2**N):
        k = Cost[i-1][0] | j
        dp[i][j] = min(dp[i-1][j], dp[i][j])
        dp[i][k] = min([dp[i-1][j] + Cost[i-1][1], dp[i-1][k], dp[i][k]]) j range(2**N) range 2**N 2 N k = Cost[i-1][0] | j k Cost[i-1][0] | j Cost[i-1][0] [i-1] Cost i-1 i 1 0 j dp[i][j] = min(dp[i-1][j], dp[i][j]) dp[i][j] [i] dp i 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][k] = min([dp[i-1][j] + Cost[i-1][1], dp[i-1][k], dp[i][k]]) dp[i][k] [i] dp i k min([dp[i-1][j] + Cost[i-1][1], dp[i-1][k], dp[i][k]]) min [dp[i-1][j] + Cost[i-1][1], dp[i-1][k], dp[i][k]] dp[i-1][j] + Cost[i-1][1] dp[i-1][j] [i-1] dp i-1 i 1 j Cost[i-1][1] [i-1] Cost i-1 i 1 1 dp[i-1][k] [i-1] dp i-1 i 1 k dp[i][k] [i] dp i k if dp[M][2**N-1] == float("inf"):
    print(-1)
else:
    print(dp[M][2**N-1]) dp[M][2**N-1] == float("inf") dp[M][2**N-1] [M] dp M 2**N-1 2**N 2 N 1 float("inf") float "inf" print(-1) print -1 print(dp[M][2**N-1]) print dp[M][2**N-1] [M] dp M 2**N-1 2**N 2 N 1 N, M = map(int, input().split()) map(int, input().split()) N a, b = map(int, input().split()) map(int, input().split()) a K = list(map(int, input().split())) list(map(int, input().split())) K k = Cost[i-1][0] | j Cost[i-1][0] | j k c += 2**(K[j]-1) 2**(K[j]-1) c dp = [[float("inf")]*(2**N+1) for _ in range(M+1)] [[float("inf")]*(2**N+1) for _ in range(M+1)] dp b = map(int, input().split()) map(int, input().split()) b M = map(int, input().split()) map(int, input().split()) M Cost = [] [] Cost c = 0 0 c
N, M = map(int, input().split())
Cost = []
for i in range(M):
    a, b = map(int, input().split())
    c = 0
    K = list(map(int, input().split()))
    for j in range(b):
        c += 2**(K[j]-1)
    Cost.append([c, a])

dp = [[float("inf")]*(2**N+1) for _ in range(M+1)]
for i in range(M+1):
    dp[i][0] = 0

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

if dp[M][2**N-1] == float("inf"):
    print(-1)
else:
    print(dp[M][2**N-1])
