import sys
readline = sys.stdin.readline

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

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

if dp[-1] == INF:
  print(-1)
else:
  print(dp[-1]) import sys sys readline = sys.stdin.readline readline sys.stdin.readline sys.stdin sys stdin readline N,M = map(int,readline().split()) N map(int,readline().split()) map int readline().split() ().split () readline 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,readline().split())
  c = list(map(int,readline().split()))
  key = 0
  for j in range(len(c)):
    key += (1 << (c[j] - 1))
  for j in range(len(dp)):
    if dp[j] == INF:
      continue
    if j | key == j:
      continue
    if dp[j | key] > dp[j] + a:
      dp[j | key] = dp[j] + a i range(M) range M a,b = map(int,readline().split()) a map(int,readline().split()) map int readline().split() ().split () readline split b c = list(map(int,readline().split())) c list(map(int,readline().split())) list map(int,readline().split()) map int readline().split() ().split () readline 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)):
    if dp[j] == INF:
      continue
    if j | key == j:
      continue
    if dp[j | key] > dp[j] + a:
      dp[j | key] = dp[j] + a j range(len(dp)) range len(dp) len dp if dp[j] == INF:
      continue
     dp[j] == INF dp[j] dp j INF continue if j | key == j:
      continue
     j | key == j j | key j key j continue if dp[j | key] > dp[j] + a:
      dp[j | key] = dp[j] + a dp[j | key] > dp[j] + a dp[j | key] dp j | key j key dp[j] + a dp[j] dp j a dp[j | key] = dp[j] + a dp[j | key] dp j | key j key dp[j] + a dp[j] dp j a if dp[-1] == INF:
  print(-1)
else:
  print(dp[-1]) dp[-1] == INF dp[-1] dp -1 INF print(-1) print -1 print(dp[-1]) print dp[-1] dp -1 INF = 10 ** 10 10 ** 10 INF readline = sys.stdin.readline sys.stdin.readline readline dp = [INF] * (2 ** N) [INF] * (2 ** N) dp a,b = map(int,readline().split()) map(int,readline().split()) a N,M = map(int,readline().split()) map(int,readline().split()) N M = map(int,readline().split()) map(int,readline().split()) M b = map(int,readline().split()) map(int,readline().split()) b c = list(map(int,readline().split())) list(map(int,readline().split())) c key += (1 << (c[j] - 1)) 1 << (c[j] - 1) key key = 0 0 key
import sys
readline = sys.stdin.readline

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

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

if dp[-1] == INF:
  print(-1)
else:
  print(dp[-1])