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

cost=[0]*m

keys=[0]*m

for i in range(m):

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

  cost[i]=a

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

  for j in range(b):

    keys[i]|=(1<<(k[j]-1))



INF=10**9+1

dp=[INF]*(2**n)

dp[0]=0

for i in range(len(keys)):

  for j in range(len(dp)-1,-1,-1):

    if dp[j]!=INF:

      dp[j|keys[i]]=min(dp[j|keys[i]],dp[j]+cost[i])

if dp[-1]!=INF:

  print((dp[-1]))

else:

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

cost=[0]*m

keys=[0]*m

for i in range(m):

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

  cost[i]=a

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

  for j in range(b):

    keys[i]|=(1<<(k[j]-1))



INF=10**9+1

dp=[INF]*(2**n)

dp[0]=0

for i in range(len(keys)):

  for j in range(len(dp)-1,-1,-1):

    if dp[j]!=INF:

      if dp[j|keys[i]]>dp[j]+cost[i]:

        dp[j|keys[i]]=dp[j]+cost[i]



if dp[-1]!=INF:

  print((dp[-1]))

else:

  print((-1))
n, m = list(map(int, input().split()))
cost = [0] * m
keys = [0] * m
for i in range(m):
    a, b = list(map(int, input().split()))
    cost[i] = a
    k = list(map(int, input().split()))
    for j in range(b):
        keys[i] |= 1 << (k[j] - 1)
INF = 10**9 + 1
dp = [INF] * (2**n)
dp[0] = 0
for i in range(len(keys)):
    for j in range(len(dp) - 1, -1, -1):
        if dp[j] != INF:
            dp[j | keys[i]] = min(dp[j | keys[i]], dp[j] + cost[i])
if dp[-1] != INF:
    print((dp[-1]))
else:
    print((-1))

n, m = list(map(int, input().split()))
cost = [0] * m
keys = [0] * m
for i in range(m):
    a, b = list(map(int, input().split()))
    cost[i] = a
    k = list(map(int, input().split()))
    for j in range(b):
        keys[i] |= 1 << (k[j] - 1)
INF = 10**9 + 1
dp = [INF] * (2**n)
dp[0] = 0
for i in range(len(keys)):
    for j in range(len(dp) - 1, -1, -1):
        if dp[j] != INF:
            if dp[j | keys[i]] > dp[j] + cost[i]:
                dp[j | keys[i]] = dp[j] + cost[i]
if dp[-1] != INF:
    print((dp[-1]))
else:
    print((-1))

-            dp[j | keys[i]] = min(dp[j | keys[i]], dp[j] + cost[i]) +            if dp[j | keys[i]] > dp[j] + cost[i]: +                dp[j | keys[i]] = dp[j] + cost[i]