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

c = []

a = []

for _ in range(m):

    ai, bi = list(map(int, input().split()))

    ci = list([2 ** (int(x) - 1) for x in input().split()])

    a.append(ai)

    c.append(sum(ci))



INF = 100 ** 18

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

dp[0] = 0

for i in range(m):

    for j in range(0, 2**n):

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



ans = dp[2**n-1]

if ans == INF:

    print((-1))

    exit()

print(ans)



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

ac = []

for _ in range(m):

    ai, bi = list(map(int, input().split()))

    ci = list([2 ** (int(x) - 1) for x in input().split()])

    ac.append((ai, sum(ci)))



INF = 100 ** 18

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

dp[0] = 0

for ai, ci in ac:

    for j in range(0, 2**n):

        dp[j | ci] = min(dp[j | ci], dp[j] + ai)



ans = dp[2**n-1]

if ans == INF:

    print((-1))

    exit()

print(ans)



n, m = list(map(int, input().split()))
c = []
a = []
for _ in range(m):
    ai, bi = list(map(int, input().split()))
    ci = list([2 ** (int(x) - 1) for x in input().split()])
    a.append(ai)
    c.append(sum(ci))
INF = 100**18
dp = [INF] * (2**n)
dp[0] = 0
for i in range(m):
    for j in range(0, 2**n):
        dp[j | c[i]] = min(dp[j | c[i]], dp[j] + a[i])
ans = dp[2**n - 1]
if ans == INF:
    print((-1))
    exit()
print(ans)

n, m = list(map(int, input().split()))
ac = []
for _ in range(m):
    ai, bi = list(map(int, input().split()))
    ci = list([2 ** (int(x) - 1) for x in input().split()])
    ac.append((ai, sum(ci)))
INF = 100**18
dp = [INF] * (2**n)
dp[0] = 0
for ai, ci in ac:
    for j in range(0, 2**n):
        dp[j | ci] = min(dp[j | ci], dp[j] + ai)
ans = dp[2**n - 1]
if ans == INF:
    print((-1))
    exit()
print(ans)

-c = [] -a = [] +ac = [] -    a.append(ai) -    c.append(sum(ci)) +    ac.append((ai, sum(ci))) -for i in range(m): +for ai, ci in ac: -        dp[j | c[i]] = min(dp[j | c[i]], dp[j] + a[i]) +        dp[j | ci] = min(dp[j | ci], dp[j] + ai)