def solve():
  ans = 0
  N, M = map(int, input().split())
  A,C = [0]*M,[0]*M
  for i in range(M):
    A[i],b = map(int, input().split())
    c = list(map(int, input().split()))
    for j in range(b):
      C[i] += 1<<(c[j]-1)
  dp = [float('inf')]*(1<<N)
  dp[0] = 0
  for i in range(1,(1<<N)+1):
    for key in range(M):
      if C[key] & i == 0:
        continue
      dp[i] = min(dp[i],dp[i&~C[key]]+A[key])
  ans = dp[-1]
  if ans==float('inf'):
    return -1
  return ans
print(solve()) def solve():
  ans = 0
  N, M = map(int, input().split())
  A,C = [0]*M,[0]*M
  for i in range(M):
    A[i],b = map(int, input().split())
    c = list(map(int, input().split()))
    for j in range(b):
      C[i] += 1<<(c[j]-1)
  dp = [float('inf')]*(1<<N)
  dp[0] = 0
  for i in range(1,(1<<N)+1):
    for key in range(M):
      if C[key] & i == 0:
        continue
      dp[i] = min(dp[i],dp[i&~C[key]]+A[key])
  ans = dp[-1]
  if ans==float('inf'):
    return -1
  return ans solve ans = 0 ans 0 N, M = map(int, input().split()) N map(int, input().split()) map int input().split() ().split () input split M A,C = [0]*M,[0]*M A [0]*M [0] 0 M C [0]*M [0] 0 M for i in range(M):
    A[i],b = map(int, input().split())
    c = list(map(int, input().split()))
    for j in range(b):
      C[i] += 1<<(c[j]-1)
   i range(M) range M A[i],b = map(int, input().split()) A[i] A i 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 for j in range(b):
      C[i] += 1<<(c[j]-1)
   j range(b) range b C[i] += 1<<(c[j]-1) C[i] C i 1<<(c[j]-1) 1 c[j]-1 c[j] c j 1 dp = [float('inf')]*(1<<N) dp [float('inf')]*(1<<N) [float('inf')] float('inf') float 'inf' 1<<N 1 N dp[0] = 0 dp[0] dp 0 0 for i in range(1,(1<<N)+1):
    for key in range(M):
      if C[key] & i == 0:
        continue
      dp[i] = min(dp[i],dp[i&~C[key]]+A[key])
   i range(1,(1<<N)+1) range 1 (1<<N)+1 1<<N 1 N 1 for key in range(M):
      if C[key] & i == 0:
        continue
      dp[i] = min(dp[i],dp[i&~C[key]]+A[key])
   key range(M) range M if C[key] & i == 0:
        continue
       C[key] & i == 0 C[key] & i C[key] C key i 0 continue dp[i] = min(dp[i],dp[i&~C[key]]+A[key]) dp[i] dp i min(dp[i],dp[i&~C[key]]+A[key]) min dp[i] dp i dp[i&~C[key]]+A[key] dp[i&~C[key]] dp i&~C[key] i ~C[key] C[key] C key A[key] A key ans = dp[-1] ans dp[-1] dp -1 if ans==float('inf'):
    return -1
   ans==float('inf') ans float('inf') float 'inf' return -1 -1 return ans ans print(solve()) print solve() solve def solve():
  ans = 0
  N, M = map(int, input().split())
  A,C = [0]*M,[0]*M
  for i in range(M):
    A[i],b = map(int, input().split())
    c = list(map(int, input().split()))
    for j in range(b):
      C[i] += 1<<(c[j]-1)
  dp = [float('inf')]*(1<<N)
  dp[0] = 0
  for i in range(1,(1<<N)+1):
    for key in range(M):
      if C[key] & i == 0:
        continue
      dp[i] = min(dp[i],dp[i&~C[key]]+A[key])
  ans = dp[-1]
  if ans==float('inf'):
    return -1
  return ans def solve():
  ans = 0
  N, M = map(int, input().split())
  A,C = [0]*M,[0]*M
  for i in range(M):
    A[i],b = map(int, input().split())
    c = list(map(int, input().split()))
    for j in range(b):
      C[i] += 1<<(c[j]-1)
  dp = [float('inf')]*(1<<N)
  dp[0] = 0
  for i in range(1,(1<<N)+1):
    for key in range(M):
      if C[key] & i == 0:
        continue
      dp[i] = min(dp[i],dp[i&~C[key]]+A[key])
  ans = dp[-1]
  if ans==float('inf'):
    return -1
  return ans solve
def solve():
  ans = 0
  N, M = map(int, input().split())
  A,C = [0]*M,[0]*M
  for i in range(M):
    A[i],b = map(int, input().split())
    c = list(map(int, input().split()))
    for j in range(b):
      C[i] += 1<<(c[j]-1)
  dp = [float('inf')]*(1<<N)
  dp[0] = 0
  for i in range(1,(1<<N)+1):
    for key in range(M):
      if C[key] & i == 0:
        continue
      dp[i] = min(dp[i],dp[i&~C[key]]+A[key])
  ans = dp[-1]
  if ans==float('inf'):
    return -1
  return ans
print(solve())