n, m = list(map(int, input().split()))

ac = []

for _ in range(m):

    a, _ = list(map(int, input().split()))

    c = sum([2**(int(i)-1) for i in input().split()])

    ac.append([a, c])

dp = [float('inf')] * 2**n

dp[0] = 0

for s in range(2**n):

    for a, c in ac:

        t = s|c

        if dp[t] > dp[s] + a:

            dp[t] = dp[s] + a

ans = dp[-1]

if ans == float('inf'):

    ans = -1

print(ans)
n, m = list(map(int, input().split()))

dp = [float('inf')] * 2**n

dp[0] = 0

for _ in range(m):

    a, _ = list(map(int, input().split()))

    c = sum([2**(int(i)-1) for i in input().split()])

    for s in range(2**n):

            t = s|c

            if dp[t] > dp[s] + a:

                dp[t] = dp[s] + a

ans = dp[-1]

if ans == float('inf'):

    ans = -1

print(ans)
n, m = list(map(int, input().split()))
ac = []
for _ in range(m):
    a, _ = list(map(int, input().split()))
    c = sum([2 ** (int(i) - 1) for i in input().split()])
    ac.append([a, c])
dp = [float("inf")] * 2**n
dp[0] = 0
for s in range(2**n):
    for a, c in ac:
        t = s | c
        if dp[t] > dp[s] + a:
            dp[t] = dp[s] + a
ans = dp[-1]
if ans == float("inf"):
    ans = -1
print(ans)

n, m = list(map(int, input().split()))
dp = [float("inf")] * 2**n
dp[0] = 0
for _ in range(m):
    a, _ = list(map(int, input().split()))
    c = sum([2 ** (int(i) - 1) for i in input().split()])
    for s in range(2**n):
        t = s | c
        if dp[t] > dp[s] + a:
            dp[t] = dp[s] + a
ans = dp[-1]
if ans == float("inf"):
    ans = -1
print(ans)

-ac = [] +dp = [float("inf")] * 2**n +dp[0] = 0 -    ac.append([a, c]) -dp = [float("inf")] * 2**n -dp[0] = 0 -for s in range(2**n): -    for a, c in ac: +    for s in range(2**n):