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

dp = [pow(10, 10) for _ in range(pow(2, n))]



dp[0] = 0

for _ in range(m):

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

    cs = list(map(int, input().split()))

    d = 0

    for c in cs:

        d += pow(2, (c-1))

    for i in range(pow(2, n)):

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



if dp[pow(2,n)-1] == pow(10, 10):

    print((-1))

else:

    print((dp[pow(2,n)-1]))

import sys;input=sys.stdin.readline

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

inf = 10**18

dp = [inf]*(1<<N)

dp[0] = 0

for i in range(M):

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

    Cs = list(map(int, input().split()))

    bb = 0

    for c in Cs:

        bb += 2**(c-1)

    for x in range((1<<N)-1, -1, -1):

        dp[bb|x] = min(dp[x]+a, dp[bb|x])



#print(dp)

r = dp[(1<<N)-1]

if r != inf:

    print((dp[(1<<N)-1]))

else:

    print((-1))

n, m = list(map(int, input().split()))
dp = [pow(10, 10) for _ in range(pow(2, n))]
dp[0] = 0
for _ in range(m):
    a, b = list(map(int, input().split()))
    cs = list(map(int, input().split()))
    d = 0
    for c in cs:
        d += pow(2, (c - 1))
    for i in range(pow(2, n)):
        dp[i | d] = min(dp[i | d], dp[i] + a)
if dp[pow(2, n) - 1] == pow(10, 10):
    print((-1))
else:
    print((dp[pow(2, n) - 1]))

import sys

input = sys.stdin.readline
N, M = list(map(int, input().split()))
inf = 10**18
dp = [inf] * (1 << N)
dp[0] = 0
for i in range(M):
    a, b = list(map(int, input().split()))
    Cs = list(map(int, input().split()))
    bb = 0
    for c in Cs:
        bb += 2 ** (c - 1)
    for x in range((1 << N) - 1, -1, -1):
        dp[bb | x] = min(dp[x] + a, dp[bb | x])
# print(dp)
r = dp[(1 << N) - 1]
if r != inf:
    print((dp[(1 << N) - 1]))
else:
    print((-1))

-n, m = list(map(int, input().split())) -dp = [pow(10, 10) for _ in range(pow(2, n))] +import sys + +input = sys.stdin.readline +N, M = list(map(int, input().split())) +inf = 10**18 +dp = [inf] * (1 << N) -for _ in range(m): +for i in range(M): -    cs = list(map(int, input().split())) -    d = 0 -    for c in cs: -        d += pow(2, (c - 1)) -    for i in range(pow(2, n)): -        dp[i | d] = min(dp[i | d], dp[i] + a) -if dp[pow(2, n) - 1] == pow(10, 10): +    Cs = list(map(int, input().split())) +    bb = 0 +    for c in Cs: +        bb += 2 ** (c - 1) +    for x in range((1 << N) - 1, -1, -1): +        dp[bb | x] = min(dp[x] + a, dp[bb | x]) +# print(dp) +r = dp[(1 << N) - 1] +if r != inf: +    print((dp[(1 << N) - 1])) +else: -else: -    print((dp[pow(2, n) - 1]))