
N, M = map(int, input().split())
X = []
for i in range(M):
    a, _ = map(int, input().split())
    c = list(map(int, input().split()))
    key = sum(1 << (v - 1) for v in c)
    X.append([key, a])

INF = 10 ** 9 + 7
dp = [[INF] * (2 ** N) for _ in range(M + 1)]
dp[0][0] = 0
for i in range(M):
    for j in range(2 ** N):
        dp[i + 1][j] = min(dp[i + 1][j], dp[i][j])
        dp[i + 1][j | X[i][0]] = min(dp[i + 1][j | X[i][0]],
                                     dp[i][j] + X[i][1])

if dp[-1][-1] == 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 X = [] X [] for i in range(M):
    a, _ = map(int, input().split())
    c = list(map(int, input().split()))
    key = sum(1 << (v - 1) for v in c)
    X.append([key, a]) i range(M) range M a, _ = map(int, input().split()) a map(int, input().split()) map int input().split() ().split () input split _ c = list(map(int, input().split())) c list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split key = sum(1 << (v - 1) for v in c) key sum(1 << (v - 1) for v in c) sum 1 << (v - 1) 1 v - 1 v 1 X.append([key, a]) X.append X append [key, a] key a INF = 10 ** 9 + 7 INF 10 ** 9 + 7 10 ** 9 10 9 7 [INF] * (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) [INF] * (2 ** N) [INF] INF 2 ** N 2 N dp = [[INF] * (2 ** N) for _ in range(M + 1)] dp [[INF] * (2 ** N) for _ 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):
        dp[i + 1][j] = min(dp[i + 1][j], dp[i][j])
        dp[i + 1][j | X[i][0]] = min(dp[i + 1][j | X[i][0]],
                                     dp[i][j] + X[i][1]) i range(M) range M for j in range(2 ** N):
        dp[i + 1][j] = min(dp[i + 1][j], dp[i][j])
        dp[i + 1][j | X[i][0]] = min(dp[i + 1][j | X[i][0]],
                                     dp[i][j] + X[i][1]) 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 | X[i][0]] = min(dp[i + 1][j | X[i][0]],
                                     dp[i][j] + X[i][1]) dp[i + 1][j | X[i][0]] [i + 1] dp i + 1 i 1 j | X[i][0] j X[i][0] [i] X i 0 min(dp[i + 1][j | X[i][0]],
                                     dp[i][j] + X[i][1]) min dp[i + 1][j | X[i][0]] [i + 1] dp i + 1 i 1 j | X[i][0] j X[i][0] [i] X i 0 dp[i][j] + X[i][1] dp[i][j] [i] dp i j X[i][1] [i] X i 1 if dp[-1][-1] == INF:
    print(-1)
else:
    print(dp[-1][-1]) dp[-1][-1] == INF dp[-1][-1] [-1] dp -1 -1 INF print(-1) print -1 print(dp[-1][-1]) print dp[-1][-1] [-1] dp -1 -1 a, _ = map(int, input().split()) map(int, input().split()) a dp = [[INF] * (2 ** N) for _ in range(M + 1)] [[INF] * (2 ** N) for _ in range(M + 1)] dp _ = map(int, input().split()) map(int, input().split()) _ N, M = map(int, input().split()) map(int, input().split()) N X = [] [] X key = sum(1 << (v - 1) for v in c) sum(1 << (v - 1) for v in c) key INF = 10 ** 9 + 7 10 ** 9 + 7 INF M = map(int, input().split()) map(int, input().split()) M c = list(map(int, input().split())) list(map(int, input().split())) c

N, M = map(int, input().split())
X = []
for i in range(M):
    a, _ = map(int, input().split())
    c = list(map(int, input().split()))
    key = sum(1 << (v - 1) for v in c)
    X.append([key, a])

INF = 10 ** 9 + 7
dp = [[INF] * (2 ** N) for _ in range(M + 1)]
dp[0][0] = 0
for i in range(M):
    for j in range(2 ** N):
        dp[i + 1][j] = min(dp[i + 1][j], dp[i][j])
        dp[i + 1][j | X[i][0]] = min(dp[i + 1][j | X[i][0]],
                                     dp[i][j] + X[i][1])

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