import sys



sr = lambda: sys.stdin.readline().rstrip()

ir = lambda: int(sr())

lr = lambda: list(map(int, sr().split()))



N, M = lr()

bit_cnt = 2 ** N # 箱は最大で12個

INF = 10 ** 10

dp = [INF] * bit_cnt

dp[0] = 0

for _ in range(M):

    price, b = lr()

    open = sum([2 ** (x-1) for x in lr()]) # 1と3の箱を開ける鍵なら101となる

    for j in range(bit_cnt):

        if dp[j|open] > dp[j] + price:

            dp[j|open] = dp[j] + price



if dp[-1] == INF:

    print((-1))

else:

    print((dp[-1]))

# 解き直し08
import sys



sr = lambda: sys.stdin.readline().rstrip()

ir = lambda: int(sr())

lr = lambda: list(map(int, sr().split()))



# dfs, dp, bit全探索

# 箱が12個以下

N, M = lr()

keys = [None] * M

for i in range(M):

    a, b = lr()

    C = lr()

    bit = 0

    for c in C:

        bit += 1 << (c-1)

    keys[i] = (a, bit)



INF = 10 ** 9

dp = [INF] * 2 ** N # 2**N - 1 が全ての箱を開けられる状態の最小値

dp[0] = 0

for key in keys:

    a, bit = key

    for i in range(2 ** N):

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



print((-1 if dp[-1] == INF else dp[-1]))

import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
N, M = lr()
bit_cnt = 2**N  # 箱は最大で12個
INF = 10**10
dp = [INF] * bit_cnt
dp[0] = 0
for _ in range(M):
    price, b = lr()
    open = sum([2 ** (x - 1) for x in lr()])  # 1と3の箱を開ける鍵なら101となる
    for j in range(bit_cnt):
        if dp[j | open] > dp[j] + price:
            dp[j | open] = dp[j] + price
if dp[-1] == INF:
    print((-1))
else:
    print((dp[-1]))
# 解き直し08

import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
# dfs, dp, bit全探索
# 箱が12個以下
N, M = lr()
keys = [None] * M
for i in range(M):
    a, b = lr()
    C = lr()
    bit = 0
    for c in C:
        bit += 1 << (c - 1)
    keys[i] = (a, bit)
INF = 10**9
dp = [INF] * 2**N  # 2**N - 1 が全ての箱を開けられる状態の最小値
dp[0] = 0
for key in keys:
    a, bit = key
    for i in range(2**N):
        dp[i | bit] = min(dp[i | bit], dp[i] + a)
print((-1 if dp[-1] == INF else dp[-1]))

+# dfs, dp, bit全探索 +# 箱が12個以下 -bit_cnt = 2**N  # 箱は最大で12個 -INF = 10**10 -dp = [INF] * bit_cnt +keys = [None] * M +for i in range(M): +    a, b = lr() +    C = lr() +    bit = 0 +    for c in C: +        bit += 1 << (c - 1) +    keys[i] = (a, bit) +INF = 10**9 +dp = [INF] * 2**N  # 2**N - 1 が全ての箱を開けられる状態の最小値 -for _ in range(M): -    price, b = lr() -    open = sum([2 ** (x - 1) for x in lr()])  # 1と3の箱を開ける鍵なら101となる -    for j in range(bit_cnt): -        if dp[j | open] > dp[j] + price: -            dp[j | open] = dp[j] + price -if dp[-1] == INF: -    print((-1)) -else: -    print((dp[-1])) -# 解き直し08 +for key in keys: +    a, bit = key +    for i in range(2**N): +        dp[i | bit] = min(dp[i | bit], dp[i] + a) +print((-1 if dp[-1] == INF else dp[-1]))