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

p = 1 << n

dp = [float('inf')] * p

dp[0] = 0

for i in range(m):

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

  c = sum([1 << j - 1 for j in list(map(int, input().split()))])

  for k in range(p):

    if dp[k|c] > dp[k] + a:

      dp[k|c] = dp[k] + a

      

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

  print((-1))

else:

  print((dp[-1]))
n, m = list(map(int, input().split()))

p = 2 ** n

inf = 10 ** 9

dp = [inf] * p

dp[0] = 0

for i in range(m):

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

  c = sum([2 ** (j - 1) for j in list(map(int, input().split()))])

  for k in range(p):

    if dp[k|c] > dp[k] + a:

      dp[k|c] = dp[k] + a

      

if dp[-1] == inf:

  print((-1))

else:

  print((dp[-1]))
n, m = list(map(int, input().split()))
p = 1 << n
dp = [float("inf")] * p
dp[0] = 0
for i in range(m):
    a, b = list(map(int, input().split()))
    c = sum([1 << j - 1 for j in list(map(int, input().split()))])
    for k in range(p):
        if dp[k | c] > dp[k] + a:
            dp[k | c] = dp[k] + a
if dp[-1] == float("inf"):
    print((-1))
else:
    print((dp[-1]))

n, m = list(map(int, input().split()))
p = 2**n
inf = 10**9
dp = [inf] * p
dp[0] = 0
for i in range(m):
    a, b = list(map(int, input().split()))
    c = sum([2 ** (j - 1) for j in list(map(int, input().split()))])
    for k in range(p):
        if dp[k | c] > dp[k] + a:
            dp[k | c] = dp[k] + a
if dp[-1] == inf:
    print((-1))
else:
    print((dp[-1]))

-p = 1 << n -dp = [float("inf")] * p +p = 2**n +inf = 10**9 +dp = [inf] * p -    c = sum([1 << j - 1 for j in list(map(int, input().split()))]) +    c = sum([2 ** (j - 1) for j in list(map(int, input().split()))]) -if dp[-1] == float("inf"): +if dp[-1] == inf: