def min(a,b):
  return a if a<=b else b


def main():
  n,m=map(int,input().split())
  inf=10**9
  cost=[0]*m
  dp=[inf]*(1<<n)
  dp[0]=0
  for i in range(m):
    a,b=map(int,input().split())
    t=sum([1<<(int(x)-1) for x in input().split()])
    for s in range(1<<n):
      dp[t|s]=min(dp[t|s], dp[s]+a)
  print(-1 if dp[-1]==inf else dp[-1])
  
  
if __name__=='__main__':
  main() def min(a,b):
  return a if a<=b else b min return a if a<=b else b a if a<=b else b a<=b a b a b a a b b def main():
  n,m=map(int,input().split())
  inf=10**9
  cost=[0]*m
  dp=[inf]*(1<<n)
  dp[0]=0
  for i in range(m):
    a,b=map(int,input().split())
    t=sum([1<<(int(x)-1) for x in input().split()])
    for s in range(1<<n):
      dp[t|s]=min(dp[t|s], dp[s]+a)
  print(-1 if dp[-1]==inf else dp[-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 cost=[0]*m cost [0]*m [0] 0 m dp=[inf]*(1<<n) dp [inf]*(1<<n) [inf] inf 1<<n 1 n dp[0]=0 dp[0] dp 0 0 for i in range(m):
    a,b=map(int,input().split())
    t=sum([1<<(int(x)-1) for x in input().split()])
    for s in range(1<<n):
      dp[t|s]=min(dp[t|s], dp[s]+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 1<<(int(x)-1) for x in input().split() for x in input().split() x input().split() ().split () input split for x in input().split() 1<<(int(x)-1) 1 int(x)-1 int(x) int x 1 t=sum([1<<(int(x)-1) for x in input().split()]) t sum([1<<(int(x)-1) for x in input().split()]) sum [1<<(int(x)-1) for x in input().split()] for s in range(1<<n):
      dp[t|s]=min(dp[t|s], dp[s]+a)
   s range(1<<n) range 1<<n 1 n dp[t|s]=min(dp[t|s], dp[s]+a) dp[t|s] dp t|s t s min(dp[t|s], dp[s]+a) min dp[t|s] dp t|s t s dp[s]+a dp[s] dp s a print(-1 if dp[-1]==inf else dp[-1]) print -1 if dp[-1]==inf else dp[-1] dp[-1]==inf dp[-1] dp -1 inf -1 dp[-1] dp -1 if __name__=='__main__':
  main() __name__=='__main__' __name__ '__main__' main() main def min(a,b):
  return a if a<=b else b def min(a,b):
  return a if a<=b else b min def main():
  n,m=map(int,input().split())
  inf=10**9
  cost=[0]*m
  dp=[inf]*(1<<n)
  dp[0]=0
  for i in range(m):
    a,b=map(int,input().split())
    t=sum([1<<(int(x)-1) for x in input().split()])
    for s in range(1<<n):
      dp[t|s]=min(dp[t|s], dp[s]+a)
  print(-1 if dp[-1]==inf else dp[-1])
  
   def main():
  n,m=map(int,input().split())
  inf=10**9
  cost=[0]*m
  dp=[inf]*(1<<n)
  dp[0]=0
  for i in range(m):
    a,b=map(int,input().split())
    t=sum([1<<(int(x)-1) for x in input().split()])
    for s in range(1<<n):
      dp[t|s]=min(dp[t|s], dp[s]+a)
  print(-1 if dp[-1]==inf else dp[-1])
  
   main
def min(a,b):
  return a if a<=b else b


def main():
  n,m=map(int,input().split())
  inf=10**9
  cost=[0]*m
  dp=[inf]*(1<<n)
  dp[0]=0
  for i in range(m):
    a,b=map(int,input().split())
    t=sum([1<<(int(x)-1) for x in input().split()])
    for s in range(1<<n):
      dp[t|s]=min(dp[t|s], dp[s]+a)
  print(-1 if dp[-1]==inf else dp[-1])
  
  
if __name__=='__main__':
  main()