import sys

input = sys.stdin.readline



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



dp = [float("inf")] * ((1<<n) + 1)

dp[0] = 0



for i in range(m):

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

    c = sum(1<<(ci-1) for ci in map(int, input().split()))



    for j in range(1<<n):

        if dp[j] + a < dp[j | c]:

            dp[j | c] = dp[j] + a

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





if dp[(1<<n) - 1] == float("inf"):

    ans = -1

else:

    ans = dp[(1<<n) - 1]



print(ans)

import sys

input = sys.stdin.readline



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



# INF = float("inf")

INF = 10 ** 8

dp = [INF] * ((1<<n) + 1)

dp[0] = 0



for i in range(m):

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

    c = sum(1<<(ci-1) for ci in map(int, input().split()))



    for j in range(1<<n):

        if dp[j] + a < dp[j | c]:

            dp[j | c] = dp[j] + a

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





if dp[(1<<n) - 1] == INF:

    ans = -1

else:

    ans = dp[(1<<n) - 1]



print(ans)

import sys

input = sys.stdin.readline
n, m = list(map(int, input().split()))
dp = [float("inf")] * ((1 << n) + 1)
dp[0] = 0
for i in range(m):
    a, b = list(map(int, input().split()))
    c = sum(1 << (ci - 1) for ci in map(int, input().split()))
    for j in range(1 << n):
        if dp[j] + a < dp[j | c]:
            dp[j | c] = dp[j] + a
        # dp[j | c] = min(dp[j] + a, dp[j | c])
if dp[(1 << n) - 1] == float("inf"):
    ans = -1
else:
    ans = dp[(1 << n) - 1]
print(ans)

import sys

input = sys.stdin.readline
n, m = list(map(int, input().split()))
# INF = float("inf")
INF = 10**8
dp = [INF] * ((1 << n) + 1)
dp[0] = 0
for i in range(m):
    a, b = list(map(int, input().split()))
    c = sum(1 << (ci - 1) for ci in map(int, input().split()))
    for j in range(1 << n):
        if dp[j] + a < dp[j | c]:
            dp[j | c] = dp[j] + a
        # dp[j | c] = min(dp[j] + a, dp[j | c])
if dp[(1 << n) - 1] == INF:
    ans = -1
else:
    ans = dp[(1 << n) - 1]
print(ans)

-dp = [float("inf")] * ((1 << n) + 1) +# INF = float("inf") +INF = 10**8 +dp = [INF] * ((1 << n) + 1) -if dp[(1 << n) - 1] == float("inf"): +if dp[(1 << n) - 1] == INF: