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

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

if __name__=='__main__':
  main()