def main():
  N, M = map(int, input().split())
  inf =  10**9
  p = 1<<N
  dp = [inf]*p 
  dp[0] = 0
  for i in range(M):
    a, b = map(int, input().split())
    C = list(map(int, input().split()))
    c_bit = sum([1<<(c-1) for c in C])
    for j in range(p):
      #print(min(dp[i][j|c_bit], dp[i][j] + a))
      dp[j|c_bit] = min(dp[j|c_bit], dp[j] + a)
  if dp[p-1] == inf:
    print(-1)
  else: 
    print(int(dp[p-1]))
  
if __name__ == "__main__":
  main()  def main():
  N, M = map(int, input().split())
  inf =  10**9
  p = 1<<N
  dp = [inf]*p 
  dp[0] = 0
  for i in range(M):
    a, b = map(int, input().split())
    C = list(map(int, input().split()))
    c_bit = sum([1<<(c-1) for c in C])
    for j in range(p):
      #print(min(dp[i][j|c_bit], dp[i][j] + a))
      dp[j|c_bit] = min(dp[j|c_bit], dp[j] + a)
  if dp[p-1] == inf:
    print(-1)
  else: 
    print(int(dp[p-1]))
   main N, M = map(int, input().split()) N map(int, input().split()) map int input().split() ().split () input split M inf =  10**9 inf 10**9 10 9 p = 1<<N p 1<<N 1 N dp = [inf]*p dp [inf]*p [inf] inf p 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()))
    c_bit = sum([1<<(c-1) for c in C])
    for j in range(p):
      #print(min(dp[i][j|c_bit], dp[i][j] + a))
      dp[j|c_bit] = min(dp[j|c_bit], 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 1<<(c-1) for c in C for c in C c C for c in C 1<<(c-1) 1 c-1 c 1 c_bit = sum([1<<(c-1) for c in C]) c_bit sum([1<<(c-1) for c in C]) sum [1<<(c-1) for c in C] for j in range(p):
      #print(min(dp[i][j|c_bit], dp[i][j] + a))
      dp[j|c_bit] = min(dp[j|c_bit], dp[j] + a)
   j range(p) range p dp[j|c_bit] = min(dp[j|c_bit], dp[j] + a) dp[j|c_bit] dp j|c_bit j c_bit min(dp[j|c_bit], dp[j] + a) min dp[j|c_bit] dp j|c_bit j c_bit dp[j] + a dp[j] dp j a if dp[p-1] == inf:
    print(-1)
  else: 
    print(int(dp[p-1]))
   dp[p-1] == inf dp[p-1] dp p-1 p 1 inf print(-1) print -1 print(int(dp[p-1])) print int(dp[p-1]) int dp[p-1] dp p-1 p 1 if __name__ == "__main__":
  main()  __name__ == "__main__" __name__ "__main__" main() main def main():
  N, M = map(int, input().split())
  inf =  10**9
  p = 1<<N
  dp = [inf]*p 
  dp[0] = 0
  for i in range(M):
    a, b = map(int, input().split())
    C = list(map(int, input().split()))
    c_bit = sum([1<<(c-1) for c in C])
    for j in range(p):
      #print(min(dp[i][j|c_bit], dp[i][j] + a))
      dp[j|c_bit] = min(dp[j|c_bit], dp[j] + a)
  if dp[p-1] == inf:
    print(-1)
  else: 
    print(int(dp[p-1]))
   def main():
  N, M = map(int, input().split())
  inf =  10**9
  p = 1<<N
  dp = [inf]*p 
  dp[0] = 0
  for i in range(M):
    a, b = map(int, input().split())
    C = list(map(int, input().split()))
    c_bit = sum([1<<(c-1) for c in C])
    for j in range(p):
      #print(min(dp[i][j|c_bit], dp[i][j] + a))
      dp[j|c_bit] = min(dp[j|c_bit], dp[j] + a)
  if dp[p-1] == inf:
    print(-1)
  else: 
    print(int(dp[p-1]))
   main
def main():
  N, M = map(int, input().split())
  inf =  10**9
  p = 1<<N
  dp = [inf]*p 
  dp[0] = 0
  for i in range(M):
    a, b = map(int, input().split())
    C = list(map(int, input().split()))
    c_bit = sum([1<<(c-1) for c in C])
    for j in range(p):
      #print(min(dp[i][j|c_bit], dp[i][j] + a))
      dp[j|c_bit] = min(dp[j|c_bit], dp[j] + a)
  if dp[p-1] == inf:
    print(-1)
  else: 
    print(int(dp[p-1]))
  
if __name__ == "__main__":
  main() 