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

dp = [10**9]*(2**n)

dp[0] = 0

for _ in range(m):

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

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

  t = 0

  for x in c:

    t |= 1<<(x-1)

  for b in range(2**n):

    dp[b|t] = min(dp[b|t],dp[b]+a)

if dp[-1] > 10**8:

  print((-1))

else:

  print((dp[-1]))

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

dp = [10**9]*(2**n)

dp[0] = 0

for _ in range(m):

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

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

  t = 0

  for x in c:

    t |= 1<<(x-1)

  for b in range(2**n):

    if dp[b|t] > dp[b]+a:

      dp[b|t] = dp[b] + a

if dp[-1] > 10**8:

  print((-1))

else:

  print((dp[-1]))

n, m = list(map(int, input().split()))
dp = [10**9] * (2**n)
dp[0] = 0
for _ in range(m):
    a, _ = list(map(int, input().split()))
    c = list(map(int, input().split()))
    t = 0
    for x in c:
        t |= 1 << (x - 1)
    for b in range(2**n):
        dp[b | t] = min(dp[b | t], dp[b] + a)
if dp[-1] > 10**8:
    print((-1))
else:
    print((dp[-1]))

n, m = list(map(int, input().split()))
dp = [10**9] * (2**n)
dp[0] = 0
for _ in range(m):
    a, _ = list(map(int, input().split()))
    c = list(map(int, input().split()))
    t = 0
    for x in c:
        t |= 1 << (x - 1)
    for b in range(2**n):
        if dp[b | t] > dp[b] + a:
            dp[b | t] = dp[b] + a
if dp[-1] > 10**8:
    print((-1))
else:
    print((dp[-1]))

-        dp[b | t] = min(dp[b | t], dp[b] + a) +        if dp[b | t] > dp[b] + a: +            dp[b | t] = dp[b] + a