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



INF = 10**7

dp = [INF]*2**N

dp[0] = 0



for i in range(M):

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

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

    #d = sum((1<< (i - 1)) for i in  map(int, input().split()))  

    d = 0

    for c in c_ls:

        d += 2**(c - 1)

    for j in range(2**N):

        jord = j | d

        dp[jord] = min(dp[j] + a, dp[jord])

        

if dp[- 1] == INF:

    print((- 1))

else:

    print((dp[- 1]))
N, M = list(map(int, input().split()))



INF = 10**7

dp = [INF]*2**N

dp[0] = 0



for i in range(M):

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

    d = sum((1<< (i - 1)) for i in  map(int, input().split()))  

    for j in range(2**N):

        if dp[j] == INF:

            continue

        jord = j | d

        dp[jord] = min(dp[j] + a, dp[jord])

        

if dp[- 1] == INF:

    print((- 1))

else:

    print((dp[- 1]))
N, M = list(map(int, input().split()))
INF = 10**7
dp = [INF] * 2**N
dp[0] = 0
for i in range(M):
    a, b = list(map(int, input().split()))
    c_ls = list(map(int, input().split()))
    # d = sum((1<< (i - 1)) for i in  map(int, input().split()))
    d = 0
    for c in c_ls:
        d += 2 ** (c - 1)
    for j in range(2**N):
        jord = j | d
        dp[jord] = min(dp[j] + a, dp[jord])
if dp[-1] == INF:
    print((-1))
else:
    print((dp[-1]))

N, M = list(map(int, input().split()))
INF = 10**7
dp = [INF] * 2**N
dp[0] = 0
for i in range(M):
    a, b = list(map(int, input().split()))
    d = sum((1 << (i - 1)) for i in map(int, input().split()))
    for j in range(2**N):
        if dp[j] == INF:
            continue
        jord = j | d
        dp[jord] = min(dp[j] + a, dp[jord])
if dp[-1] == INF:
    print((-1))
else:
    print((dp[-1]))

-    c_ls = list(map(int, input().split())) -    # d = sum((1<< (i - 1)) for i in  map(int, input().split())) -    d = 0 -    for c in c_ls: -        d += 2 ** (c - 1) +    d = sum((1 << (i - 1)) for i in map(int, input().split())) +        if dp[j] == INF: +            continue