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 sys sr = lambda: sys.stdin.readline().rstrip() sr lambda: sys.stdin.readline().rstrip() sys.stdin.readline().rstrip() sys.stdin.readline().rstrip sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline rstrip ir = lambda: int(sr()) ir lambda: int(sr()) int(sr()) int sr() sr lr = lambda: list(map(int, sr().split())) lr lambda: list(map(int, sr().split())) list(map(int, sr().split())) list map(int, sr().split()) map int sr().split() ().split () sr split N, M = lr() N lr() lr M bit_cnt = 2 ** N bit_cnt 2 ** N 2 N INF = 10 ** 10 INF 10 ** 10 10 10 dp = [INF] * bit_cnt dp [INF] * bit_cnt [INF] INF bit_cnt dp[0] = 0 dp[0] 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 _ range(M) range M price, b = lr() price lr() lr b 2 ** (x-1) for x in lr() for x in lr() x lr() lr for x in lr() 2 ** (x-1) 2 x-1 x 1 open = sum([2 ** (x-1) for x in lr()]) open sum([2 ** (x-1) for x in lr()]) sum [2 ** (x-1) for x in lr()] for j in range(bit_cnt):
        if dp[j|open] > dp[j] + price:
            dp[j|open] = dp[j] + price j range(bit_cnt) range bit_cnt if dp[j|open] > dp[j] + price:
            dp[j|open] = dp[j] + price dp[j|open] > dp[j] + price dp[j|open] dp j|open j open dp[j] + price dp[j] dp j price dp[j|open] = dp[j] + price dp[j|open] dp j|open j open dp[j] + price dp[j] dp j price if dp[-1] == INF:
    print(-1)
else:
    print(dp[-1])
# 解き直し08 dp[-1] == INF dp[-1] dp -1 INF print(-1) print -1 print(dp[-1]) print dp[-1] dp -1 ir = lambda: int(sr()) lambda: int(sr()) ir price, b = lr() lr() price INF = 10 ** 10 10 ** 10 INF dp = [INF] * bit_cnt [INF] * bit_cnt dp open = sum([2 ** (x-1) for x in lr()]) sum([2 ** (x-1) for x in lr()]) open sr = lambda: sys.stdin.readline().rstrip() lambda: sys.stdin.readline().rstrip() sr N, M = lr() lr() N bit_cnt = 2 ** N 2 ** N bit_cnt M = lr() lr() M lr = lambda: list(map(int, sr().split())) lambda: list(map(int, sr().split())) lr b = lr() lr() b
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