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

AB = []

C = []

for _ in range(M):

    AB.append(list(map(int, input().split())))

    C.append(list(map(int, input().split())))



INF = 10 ** 9 + 7

dp = [INF] * (2 ** N)

dp[0] = 0



for i, ((a, b), c) in enumerate(zip(AB, C)):

    num = int("".join(["01"[int(i + 1 in c)] for i in range(N)]), 2)

    for j in range(2 ** N):

        dp[j | num] = min(dp[j | num], dp[j] + a)



print((dp[-1] if dp[-1] < INF else -1))

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

X = []

Y = []

for _ in range(M):

    X.append(list(map(int, input().split())))

    

    tmp = 0

    for i in list(map(int, input().split())):

        tmp += 2 ** (i - 1)

    Y.append(tmp)



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 | Y[i]] = min(dp[i + 1][j | Y[i]],

                                  dp[i][j] + X[i][0])



ans = min(dp[i][-1] for i in range(M + 1))

print((ans if ans < inf else -1))



N, M = list(map(int, input().split()))
AB = []
C = []
for _ in range(M):
    AB.append(list(map(int, input().split())))
    C.append(list(map(int, input().split())))
INF = 10**9 + 7
dp = [INF] * (2**N)
dp[0] = 0
for i, ((a, b), c) in enumerate(zip(AB, C)):
    num = int("".join(["01"[int(i + 1 in c)] for i in range(N)]), 2)
    for j in range(2**N):
        dp[j | num] = min(dp[j | num], dp[j] + a)
print((dp[-1] if dp[-1] < INF else -1))

N, M = list(map(int, input().split()))
X = []
Y = []
for _ in range(M):
    X.append(list(map(int, input().split())))
    tmp = 0
    for i in list(map(int, input().split())):
        tmp += 2 ** (i - 1)
    Y.append(tmp)
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 | Y[i]] = min(dp[i + 1][j | Y[i]], dp[i][j] + X[i][0])
ans = min(dp[i][-1] for i in range(M + 1))
print((ans if ans < inf else -1))

-AB = [] -C = [] +X = [] +Y = [] -    AB.append(list(map(int, input().split()))) -    C.append(list(map(int, input().split()))) -INF = 10**9 + 7 -dp = [INF] * (2**N) -dp[0] = 0 -for i, ((a, b), c) in enumerate(zip(AB, C)): -    num = int("".join(["01"[int(i + 1 in c)] for i in range(N)]), 2) +    X.append(list(map(int, input().split()))) +    tmp = 0 +    for i in list(map(int, input().split())): +        tmp += 2 ** (i - 1) +    Y.append(tmp) +inf = 10**9 + 7 +dp = [[inf] * (2**N) for _ in range(M + 1)] +dp[0][0] = 0 +for i in range(M): -        dp[j | num] = min(dp[j | num], dp[j] + a) -print((dp[-1] if dp[-1] < INF else -1)) +        dp[i + 1][j] = min(dp[i + 1][j], dp[i][j]) +        dp[i + 1][j | Y[i]] = min(dp[i + 1][j | Y[i]], dp[i][j] + X[i][0]) +ans = min(dp[i][-1] for i in range(M + 1)) +print((ans if ans < inf else -1))