n, m = map(int, input().split())
keys = []

for _ in range(m):
    cost, types = map(int, input().split())
    to_open = list(map(int, input().split()))
    keys.append([cost, to_open])

DP = [10**9] * (2**n)
DP[0] = 0

for cost, (to_open) in keys:
    openable = 0
    for open in to_open:
        openable |= 1 << (open-1)

    for opened in range(2 ** n):
        pattern = opened | openable
        DP[pattern] = min(DP[pattern], DP[opened] + cost)

full_open = 2**n - 1
ans = DP[full_open]

if ans == 10 ** 9:
    ans = -1

print(ans) n, m = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split m keys = [] keys [] for _ in range(m):
    cost, types = map(int, input().split())
    to_open = list(map(int, input().split()))
    keys.append([cost, to_open]) _ range(m) range m cost, types = map(int, input().split()) cost map(int, input().split()) map int input().split() ().split () input split types to_open = list(map(int, input().split())) to_open list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split keys.append([cost, to_open]) keys.append keys append [cost, to_open] cost to_open DP = [10**9] * (2**n) DP [10**9] * (2**n) [10**9] 10**9 10 9 2**n 2 n DP[0] = 0 DP[0] DP 0 0 for cost, (to_open) in keys:
    openable = 0
    for open in to_open:
        openable |= 1 << (open-1)

    for opened in range(2 ** n):
        pattern = opened | openable
        DP[pattern] = min(DP[pattern], DP[opened] + cost) cost to_open keys openable = 0 openable 0 for open in to_open:
        openable |= 1 << (open-1)

     open to_open openable |= 1 << (open-1) openable 1 << (open-1) 1 open-1 open 1 for opened in range(2 ** n):
        pattern = opened | openable
        DP[pattern] = min(DP[pattern], DP[opened] + cost) opened range(2 ** n) range 2 ** n 2 n pattern = opened | openable pattern opened | openable opened openable DP[pattern] = min(DP[pattern], DP[opened] + cost) DP[pattern] DP pattern min(DP[pattern], DP[opened] + cost) min DP[pattern] DP pattern DP[opened] + cost DP[opened] DP opened cost full_open = 2**n - 1 full_open 2**n - 1 2**n 2 n 1 ans = DP[full_open] ans DP[full_open] DP full_open if ans == 10 ** 9:
    ans = -1 ans == 10 ** 9 ans 10 ** 9 10 9 ans = -1 ans -1 print(ans) print ans openable = 0 0 openable ans = DP[full_open] DP[full_open] ans full_open = 2**n - 1 2**n - 1 full_open keys = [] [] keys ans = -1 -1 ans to_open = list(map(int, input().split())) list(map(int, input().split())) to_open types = map(int, input().split()) map(int, input().split()) types pattern = opened | openable opened | openable pattern DP = [10**9] * (2**n) [10**9] * (2**n) DP n, m = map(int, input().split()) map(int, input().split()) n cost, types = map(int, input().split()) map(int, input().split()) cost m = map(int, input().split()) map(int, input().split()) m openable |= 1 << (open-1) 1 << (open-1) openable
n, m = map(int, input().split())
keys = []

for _ in range(m):
    cost, types = map(int, input().split())
    to_open = list(map(int, input().split()))
    keys.append([cost, to_open])

DP = [10**9] * (2**n)
DP[0] = 0

for cost, (to_open) in keys:
    openable = 0
    for open in to_open:
        openable |= 1 << (open-1)

    for opened in range(2 ** n):
        pattern = opened | openable
        DP[pattern] = min(DP[pattern], DP[opened] + cost)

full_open = 2**n - 1
ans = DP[full_open]

if ans == 10 ** 9:
    ans = -1

print(ans)
