def main():
    INF=10**9
    n,m=map(int,input().split())
    key=[0]*m
    keycost=[0]*m

    for i in range(m):
        a,b=map(int,input().split())
        keycost[i]=a
        c=[pow(2,int(i)-1) for i in input().split()]
        key[i]=sum(c)
    
    dp=[[INF]*(m+1) for _ in range(1<<n)]
    dp[0]=[0]*(1+m)
    
    for s in range(1<<n):
        for i in range(m):
            dp[s][i+1]=min(dp[(s&key[i])^s][i]+keycost[i],dp[s][i])
    
    if dp[-1][m]==INF:
        print(-1)
    else:
        print(dp[-1][m])
 
if __name__=='__main__':
    main() def main():
    INF=10**9
    n,m=map(int,input().split())
    key=[0]*m
    keycost=[0]*m

    for i in range(m):
        a,b=map(int,input().split())
        keycost[i]=a
        c=[pow(2,int(i)-1) for i in input().split()]
        key[i]=sum(c)
    
    dp=[[INF]*(m+1) for _ in range(1<<n)]
    dp[0]=[0]*(1+m)
    
    for s in range(1<<n):
        for i in range(m):
            dp[s][i+1]=min(dp[(s&key[i])^s][i]+keycost[i],dp[s][i])
    
    if dp[-1][m]==INF:
        print(-1)
    else:
        print(dp[-1][m])
  main INF=10**9 INF 10**9 10 9 n,m=map(int,input().split()) n map(int,input().split()) map int input().split() ().split () input split m key=[0]*m key [0]*m [0] 0 m keycost=[0]*m keycost [0]*m [0] 0 m for i in range(m):
        a,b=map(int,input().split())
        keycost[i]=a
        c=[pow(2,int(i)-1) for i in input().split()]
        key[i]=sum(c)
    
     i range(m) range m a,b=map(int,input().split()) a map(int,input().split()) map int input().split() ().split () input split b keycost[i]=a keycost[i] keycost i a pow(2,int(i)-1) for i in input().split() for i in input().split() i input().split() ().split () input split for i in input().split() pow(2,int(i)-1) pow 2 int(i)-1 int(i) int i 1 c=[pow(2,int(i)-1) for i in input().split()] c [pow(2,int(i)-1) for i in input().split()] key[i]=sum(c) key[i] key i sum(c) sum c [INF]*(m+1) for _ in range(1<<n) for _ in range(1<<n) _ range(1<<n) range 1<<n 1 n for _ in range(1<<n) [INF]*(m+1) [INF] INF m+1 m 1 dp=[[INF]*(m+1) for _ in range(1<<n)] dp [[INF]*(m+1) for _ in range(1<<n)] dp[0]=[0]*(1+m) dp[0] dp 0 [0]*(1+m) [0] 0 1+m 1 m for s in range(1<<n):
        for i in range(m):
            dp[s][i+1]=min(dp[(s&key[i])^s][i]+keycost[i],dp[s][i])
    
     s range(1<<n) range 1<<n 1 n for i in range(m):
            dp[s][i+1]=min(dp[(s&key[i])^s][i]+keycost[i],dp[s][i])
    
     i range(m) range m dp[s][i+1]=min(dp[(s&key[i])^s][i]+keycost[i],dp[s][i]) dp[s][i+1] [s] dp s i+1 i 1 min(dp[(s&key[i])^s][i]+keycost[i],dp[s][i]) min dp[(s&key[i])^s][i]+keycost[i] dp[(s&key[i])^s][i] [(s&key[i])^s] dp (s&key[i])^s s&key[i] s key[i] key i s i keycost[i] keycost i dp[s][i] [s] dp s i if dp[-1][m]==INF:
        print(-1)
    else:
        print(dp[-1][m])
  dp[-1][m]==INF dp[-1][m] [-1] dp -1 m INF print(-1) print -1 print(dp[-1][m]) print dp[-1][m] [-1] dp -1 m if __name__=='__main__':
    main() __name__=='__main__' __name__ '__main__' main() main def main():
    INF=10**9
    n,m=map(int,input().split())
    key=[0]*m
    keycost=[0]*m

    for i in range(m):
        a,b=map(int,input().split())
        keycost[i]=a
        c=[pow(2,int(i)-1) for i in input().split()]
        key[i]=sum(c)
    
    dp=[[INF]*(m+1) for _ in range(1<<n)]
    dp[0]=[0]*(1+m)
    
    for s in range(1<<n):
        for i in range(m):
            dp[s][i+1]=min(dp[(s&key[i])^s][i]+keycost[i],dp[s][i])
    
    if dp[-1][m]==INF:
        print(-1)
    else:
        print(dp[-1][m])
  def main():
    INF=10**9
    n,m=map(int,input().split())
    key=[0]*m
    keycost=[0]*m

    for i in range(m):
        a,b=map(int,input().split())
        keycost[i]=a
        c=[pow(2,int(i)-1) for i in input().split()]
        key[i]=sum(c)
    
    dp=[[INF]*(m+1) for _ in range(1<<n)]
    dp[0]=[0]*(1+m)
    
    for s in range(1<<n):
        for i in range(m):
            dp[s][i+1]=min(dp[(s&key[i])^s][i]+keycost[i],dp[s][i])
    
    if dp[-1][m]==INF:
        print(-1)
    else:
        print(dp[-1][m])
  main
def main():
    INF=10**9
    n,m=map(int,input().split())
    key=[0]*m
    keycost=[0]*m

    for i in range(m):
        a,b=map(int,input().split())
        keycost[i]=a
        c=[pow(2,int(i)-1) for i in input().split()]
        key[i]=sum(c)
    
    dp=[[INF]*(m+1) for _ in range(1<<n)]
    dp[0]=[0]*(1+m)
    
    for s in range(1<<n):
        for i in range(m):
            dp[s][i+1]=min(dp[(s&key[i])^s][i]+keycost[i],dp[s][i])
    
    if dp[-1][m]==INF:
        print(-1)
    else:
        print(dp[-1][m])
 
if __name__=='__main__':
    main()