import sys
input = sys.stdin.readline

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    import itertools
    
    mod=10**9+7
    N,M=MI()
    a=[0]*M
    b=[0]*M
    c=[]
    
    for i in range(M):
        a[i],b[i]=MI()
        cc=LI()
        for j in range(b[i]):
            cc[j]-=1
        c.append(cc)
        
    N2=pow(2,N)
    inf=10**10
    
    def encode(L):
        temp=0
        for i in range(len(L)):
            temp+=L[i]<<i
        return temp
            
    
    dp=[[inf]*N2 for _ in range(M+1)]
    # i番目の鍵までで状態jを達成できる最小値
    
    dp[0][0]=0
    for i in range(M):
        for ite in itertools.product([0,1], repeat=N):
            L=list(ite)
            j=encode(L)
            for k in c[i]:
                L[k]=1
            nj=encode(L)
            # print(i,ite,j,nj)
            if dp[i][j]!=inf:
                dp[i+1][j]=min(dp[i+1][j], dp[i][j])
                dp[i+1][nj]=min(dp[i+1][nj], dp[i][j]+a[i])
        
    ans=dp[-1][-1]
    if ans==inf:
        ans=-1
    print(ans)
    
    # for i in range(M+1):
    #     print(dp[i])
                
    

main() import sys sys input = sys.stdin.readline input sys.stdin.readline sys.stdin sys stdin readline def I(): return int(input()) I def MI(): return map(int, input().split()) MI def LI(): return list(map(int, input().split())) LI def main():
    import itertools
    
    mod=10**9+7
    N,M=MI()
    a=[0]*M
    b=[0]*M
    c=[]
    
    for i in range(M):
        a[i],b[i]=MI()
        cc=LI()
        for j in range(b[i]):
            cc[j]-=1
        c.append(cc)
        
    N2=pow(2,N)
    inf=10**10
    
    def encode(L):
        temp=0
        for i in range(len(L)):
            temp+=L[i]<<i
        return temp
            
    
    dp=[[inf]*N2 for _ in range(M+1)]
    # i番目の鍵までで状態jを達成できる最小値
    
    dp[0][0]=0
    for i in range(M):
        for ite in itertools.product([0,1], repeat=N):
            L=list(ite)
            j=encode(L)
            for k in c[i]:
                L[k]=1
            nj=encode(L)
            # print(i,ite,j,nj)
            if dp[i][j]!=inf:
                dp[i+1][j]=min(dp[i+1][j], dp[i][j])
                dp[i+1][nj]=min(dp[i+1][nj], dp[i][j]+a[i])
        
    ans=dp[-1][-1]
    if ans==inf:
        ans=-1
    print(ans)
    
    # for i in range(M+1):
    #     print(dp[i])
                
     main import itertools itertools mod=10**9+7 mod 10**9+7 10**9 10 9 7 N,M=MI() N MI() MI M a=[0]*M a [0]*M [0] 0 M b=[0]*M b [0]*M [0] 0 M c=[] c [] for i in range(M):
        a[i],b[i]=MI()
        cc=LI()
        for j in range(b[i]):
            cc[j]-=1
        c.append(cc)
        
     i range(M) range M a[i],b[i]=MI() a[i] a i MI() MI b[i] b i cc=LI() cc LI() LI for j in range(b[i]):
            cc[j]-=1
         j range(b[i]) range b[i] b i cc[j]-=1 cc[j] cc j 1 c.append(cc) c.append c append cc N2=pow(2,N) N2 pow(2,N) pow 2 N inf=10**10 inf 10**10 10 10 def encode(L):
        temp=0
        for i in range(len(L)):
            temp+=L[i]<<i
        return temp
            
    
     encode temp=0 temp 0 for i in range(len(L)):
            temp+=L[i]<<i
         i range(len(L)) range len(L) len L temp+=L[i]<<i temp L[i]<<i L[i] L i i return temp temp L L [inf]*N2 for _ in range(M+1) for _ in range(M+1) _ range(M+1) range M+1 M 1 for _ in range(M+1) [inf]*N2 [inf] inf N2 dp=[[inf]*N2 for _ in range(M+1)] dp [[inf]*N2 for _ in range(M+1)] dp[0][0]=0 dp[0][0] [0] dp 0 0 0 for i in range(M):
        for ite in itertools.product([0,1], repeat=N):
            L=list(ite)
            j=encode(L)
            for k in c[i]:
                L[k]=1
            nj=encode(L)
            # print(i,ite,j,nj)
            if dp[i][j]!=inf:
                dp[i+1][j]=min(dp[i+1][j], dp[i][j])
                dp[i+1][nj]=min(dp[i+1][nj], dp[i][j]+a[i])
        
     i range(M) range M for ite in itertools.product([0,1], repeat=N):
            L=list(ite)
            j=encode(L)
            for k in c[i]:
                L[k]=1
            nj=encode(L)
            # print(i,ite,j,nj)
            if dp[i][j]!=inf:
                dp[i+1][j]=min(dp[i+1][j], dp[i][j])
                dp[i+1][nj]=min(dp[i+1][nj], dp[i][j]+a[i])
        
     ite itertools.product([0,1], repeat=N) itertools.product itertools product [0,1] 0 1 repeat=N repeat N L=list(ite) L list(ite) list ite j=encode(L) j encode(L) encode L for k in c[i]:
                L[k]=1
             k c[i] c i L[k]=1 L[k] L k 1 nj=encode(L) nj encode(L) encode L if dp[i][j]!=inf:
                dp[i+1][j]=min(dp[i+1][j], dp[i][j])
                dp[i+1][nj]=min(dp[i+1][nj], dp[i][j]+a[i])
        
     dp[i][j]!=inf dp[i][j] [i] dp i j inf dp[i+1][j]=min(dp[i+1][j], dp[i][j]) dp[i+1][j] [i+1] dp i+1 i 1 j min(dp[i+1][j], dp[i][j]) min dp[i+1][j] [i+1] dp i+1 i 1 j dp[i][j] [i] dp i j dp[i+1][nj]=min(dp[i+1][nj], dp[i][j]+a[i]) dp[i+1][nj] [i+1] dp i+1 i 1 nj min(dp[i+1][nj], dp[i][j]+a[i]) min dp[i+1][nj] [i+1] dp i+1 i 1 nj dp[i][j]+a[i] dp[i][j] [i] dp i j a[i] a i ans=dp[-1][-1] ans dp[-1][-1] [-1] dp -1 -1 if ans==inf:
        ans=-1
     ans==inf ans inf ans=-1 ans -1 print(ans) print ans main() main def MI(): return map(int, input().split()) def MI(): return map(int, input().split()) MI def LI(): return list(map(int, input().split())) def LI(): return list(map(int, input().split())) LI def main():
    import itertools
    
    mod=10**9+7
    N,M=MI()
    a=[0]*M
    b=[0]*M
    c=[]
    
    for i in range(M):
        a[i],b[i]=MI()
        cc=LI()
        for j in range(b[i]):
            cc[j]-=1
        c.append(cc)
        
    N2=pow(2,N)
    inf=10**10
    
    def encode(L):
        temp=0
        for i in range(len(L)):
            temp+=L[i]<<i
        return temp
            
    
    dp=[[inf]*N2 for _ in range(M+1)]
    # i番目の鍵までで状態jを達成できる最小値
    
    dp[0][0]=0
    for i in range(M):
        for ite in itertools.product([0,1], repeat=N):
            L=list(ite)
            j=encode(L)
            for k in c[i]:
                L[k]=1
            nj=encode(L)
            # print(i,ite,j,nj)
            if dp[i][j]!=inf:
                dp[i+1][j]=min(dp[i+1][j], dp[i][j])
                dp[i+1][nj]=min(dp[i+1][nj], dp[i][j]+a[i])
        
    ans=dp[-1][-1]
    if ans==inf:
        ans=-1
    print(ans)
    
    # for i in range(M+1):
    #     print(dp[i])
                
     def main():
    import itertools
    
    mod=10**9+7
    N,M=MI()
    a=[0]*M
    b=[0]*M
    c=[]
    
    for i in range(M):
        a[i],b[i]=MI()
        cc=LI()
        for j in range(b[i]):
            cc[j]-=1
        c.append(cc)
        
    N2=pow(2,N)
    inf=10**10
    
    def encode(L):
        temp=0
        for i in range(len(L)):
            temp+=L[i]<<i
        return temp
            
    
    dp=[[inf]*N2 for _ in range(M+1)]
    # i番目の鍵までで状態jを達成できる最小値
    
    dp[0][0]=0
    for i in range(M):
        for ite in itertools.product([0,1], repeat=N):
            L=list(ite)
            j=encode(L)
            for k in c[i]:
                L[k]=1
            nj=encode(L)
            # print(i,ite,j,nj)
            if dp[i][j]!=inf:
                dp[i+1][j]=min(dp[i+1][j], dp[i][j])
                dp[i+1][nj]=min(dp[i+1][nj], dp[i][j]+a[i])
        
    ans=dp[-1][-1]
    if ans==inf:
        ans=-1
    print(ans)
    
    # for i in range(M+1):
    #     print(dp[i])
                
     main def I(): return int(input()) def I(): return int(input()) I input = sys.stdin.readline sys.stdin.readline input
import sys
input = sys.stdin.readline

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    import itertools
    
    mod=10**9+7
    N,M=MI()
    a=[0]*M
    b=[0]*M
    c=[]
    
    for i in range(M):
        a[i],b[i]=MI()
        cc=LI()
        for j in range(b[i]):
            cc[j]-=1
        c.append(cc)
        
    N2=pow(2,N)
    inf=10**10
    
    def encode(L):
        temp=0
        for i in range(len(L)):
            temp+=L[i]<<i
        return temp
            
    
    dp=[[inf]*N2 for _ in range(M+1)]
    # i番目の鍵までで状態jを達成できる最小値
    
    dp[0][0]=0
    for i in range(M):
        for ite in itertools.product([0,1], repeat=N):
            L=list(ite)
            j=encode(L)
            for k in c[i]:
                L[k]=1
            nj=encode(L)
            # print(i,ite,j,nj)
            if dp[i][j]!=inf:
                dp[i+1][j]=min(dp[i+1][j], dp[i][j])
                dp[i+1][nj]=min(dp[i+1][nj], dp[i][j]+a[i])
        
    ans=dp[-1][-1]
    if ans==inf:
        ans=-1
    print(ans)
    
    # for i in range(M+1):
    #     print(dp[i])
                
    

main()
