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

key = []

for _ in range(M):

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

  s = 0

  C = list([int(x)-1 for x in input().split()])

  for c in C:

    s |= 1<<c

  key += [(s, a)]

  

dp = [float('inf')]*(1<<N)

dp[0] = 0

for s in range(1<<N):

  for i in range(M):

    t = s | key[i][0] # 遷移先

    cost = dp[s] + key[i][1]

    dp[t] = min(dp[t], cost)

if dp[-1] == float('inf'):

  print((-1))

else:

  print((dp[-1]))









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

keys = []

for _ in range(M):

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

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

  s = 0

  for cc in c:

    cc -= 1

    s |= 1<<cc

  keys += [(s, a)]



dp = [float('inf')]*(1<<N)

dp[0] = 0

for s in range(1<<N):

  for i in range(M):

    t = s | keys[i][0]

    dp[t] = min(dp[t], keys[i][1]+dp[s])



if dp[-1] == float('inf'):

  print((-1))

else:

  print((dp[-1]))
N, M = list(map(int, input().split()))
key = []
for _ in range(M):
    a, b = list(map(int, input().split()))
    s = 0
    C = list([int(x) - 1 for x in input().split()])
    for c in C:
        s |= 1 << c
    key += [(s, a)]
dp = [float("inf")] * (1 << N)
dp[0] = 0
for s in range(1 << N):
    for i in range(M):
        t = s | key[i][0]  # 遷移先
        cost = dp[s] + key[i][1]
        dp[t] = min(dp[t], cost)
if dp[-1] == float("inf"):
    print((-1))
else:
    print((dp[-1]))

N, M = list(map(int, input().split()))
keys = []
for _ in range(M):
    a, b = list(map(int, input().split()))
    c = list(map(int, input().split()))
    s = 0
    for cc in c:
        cc -= 1
        s |= 1 << cc
    keys += [(s, a)]
dp = [float("inf")] * (1 << N)
dp[0] = 0
for s in range(1 << N):
    for i in range(M):
        t = s | keys[i][0]
        dp[t] = min(dp[t], keys[i][1] + dp[s])
if dp[-1] == float("inf"):
    print((-1))
else:
    print((dp[-1]))

-key = [] +keys = [] +    c = list(map(int, input().split())) -    C = list([int(x) - 1 for x in input().split()]) -    for c in C: -        s |= 1 << c -    key += [(s, a)] +    for cc in c: +        cc -= 1 +        s |= 1 << cc +    keys += [(s, a)] -        t = s | key[i][0]  # 遷移先 -        cost = dp[s] + key[i][1] -        dp[t] = min(dp[t], cost) +        t = s | keys[i][0] +        dp[t] = min(dp[t], keys[i][1] + dp[s])