N,M = map(int,input().split())
INF = 10 ** 10
dp = [INF] * (2 ** N)
dp[0] = 0

for i in range(M):
  a,b = map(int,input().split())
  c = list(map(int,input().split()))
  key = 0
  for j in range(len(c)):
    key += (1 << (c[j] - 1))
  for j in range(len(dp) - 1, -1, -1):
    if dp[j] == INF:
      continue
    dp[j | key] = min(dp[j | key], dp[j] + a)

print((dp[-1], -1)[dp[-1] == INF]) N,M = map(int,input().split()) N map(int,input().split()) map int input().split() ().split () input split M INF = 10 ** 10 INF 10 ** 10 10 10 dp = [INF] * (2 ** N) dp [INF] * (2 ** N) [INF] INF 2 ** N 2 N dp[0] = 0 dp[0] dp 0 0 for i in range(M):
  a,b = map(int,input().split())
  c = list(map(int,input().split()))
  key = 0
  for j in range(len(c)):
    key += (1 << (c[j] - 1))
  for j in range(len(dp) - 1, -1, -1):
    if dp[j] == INF:
      continue
    dp[j | key] = min(dp[j | key], dp[j] + a) i range(M) range M a,b = map(int,input().split()) a map(int,input().split()) map int input().split() ().split () input split b c = list(map(int,input().split())) c list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split key = 0 key 0 for j in range(len(c)):
    key += (1 << (c[j] - 1))
   j range(len(c)) range len(c) len c key += (1 << (c[j] - 1)) key 1 << (c[j] - 1) 1 c[j] - 1 c[j] c j 1 for j in range(len(dp) - 1, -1, -1):
    if dp[j] == INF:
      continue
    dp[j | key] = min(dp[j | key], dp[j] + a) j range(len(dp) - 1, -1, -1) range len(dp) - 1 len(dp) len dp 1 -1 -1 if dp[j] == INF:
      continue
     dp[j] == INF dp[j] dp j INF continue dp[j | key] = min(dp[j | key], dp[j] + a) dp[j | key] dp j | key j key min(dp[j | key], dp[j] + a) min dp[j | key] dp j | key j key dp[j] + a dp[j] dp j a print((dp[-1], -1)[dp[-1] == INF]) print (dp[-1], -1)[dp[-1] == INF] (dp[-1], -1) dp[-1] dp -1 -1 dp[-1] == INF dp[-1] dp -1 INF b = map(int,input().split()) map(int,input().split()) b key += (1 << (c[j] - 1)) 1 << (c[j] - 1) key a,b = map(int,input().split()) map(int,input().split()) a c = list(map(int,input().split())) list(map(int,input().split())) c M = map(int,input().split()) map(int,input().split()) M key = 0 0 key INF = 10 ** 10 10 ** 10 INF N,M = map(int,input().split()) map(int,input().split()) N dp = [INF] * (2 ** N) [INF] * (2 ** N) dp
N,M = map(int,input().split())
INF = 10 ** 10
dp = [INF] * (2 ** N)
dp[0] = 0

for i in range(M):
  a,b = map(int,input().split())
  c = list(map(int,input().split()))
  key = 0
  for j in range(len(c)):
    key += (1 << (c[j] - 1))
  for j in range(len(dp) - 1, -1, -1):
    if dp[j] == INF:
      continue
    dp[j | key] = min(dp[j | key], dp[j] + a)

print((dp[-1], -1)[dp[-1] == INF])