from sys import stdin
def main():
    #入力
    readline=stdin.readline
    n,m=map(int,readline().split())
    a=[0]*m
    b=[0]*m
    c=[0]*m
    for i in range(m):
        a[i],b[i]=map(int,readline().split())
        li=list(map(int,readline().split()))
        for j in range(len(li)):
            c[i]|=1<<(li[j]-1)

    inf=10**9
    dp=[[inf]*(1<<n) for _ in range(m+1)]
    dp[0][0]=0
    for i in range(1,m+1):
        for j in range(1<<n):
            #i番目の鍵を使わない
            dp[i][j]=min(dp[i-1][j],dp[i][j])

            #i番目の鍵を使う
            dp[i][j|c[i-1]]=min(dp[i][j|c[i-1]],dp[i-1][j]+a[i-1])

    ans=dp[m][(1<<n)-1]
    print(ans if ans<inf else -1)

if __name__=="__main__":
    main() from sys import stdin def main():
    #入力
    readline=stdin.readline
    n,m=map(int,readline().split())
    a=[0]*m
    b=[0]*m
    c=[0]*m
    for i in range(m):
        a[i],b[i]=map(int,readline().split())
        li=list(map(int,readline().split()))
        for j in range(len(li)):
            c[i]|=1<<(li[j]-1)

    inf=10**9
    dp=[[inf]*(1<<n) for _ in range(m+1)]
    dp[0][0]=0
    for i in range(1,m+1):
        for j in range(1<<n):
            #i番目の鍵を使わない
            dp[i][j]=min(dp[i-1][j],dp[i][j])

            #i番目の鍵を使う
            dp[i][j|c[i-1]]=min(dp[i][j|c[i-1]],dp[i-1][j]+a[i-1])

    ans=dp[m][(1<<n)-1]
    print(ans if ans<inf else -1) main readline=stdin.readline readline stdin.readline stdin readline n,m=map(int,readline().split()) n map(int,readline().split()) map int readline().split() ().split () readline split m a=[0]*m a [0]*m [0] 0 m b=[0]*m b [0]*m [0] 0 m c=[0]*m c [0]*m [0] 0 m for i in range(m):
        a[i],b[i]=map(int,readline().split())
        li=list(map(int,readline().split()))
        for j in range(len(li)):
            c[i]|=1<<(li[j]-1)

     i range(m) range m a[i],b[i]=map(int,readline().split()) a[i] a i map(int,readline().split()) map int readline().split() ().split () readline split b[i] b i li=list(map(int,readline().split())) li list(map(int,readline().split())) list map(int,readline().split()) map int readline().split() ().split () readline split for j in range(len(li)):
            c[i]|=1<<(li[j]-1)

     j range(len(li)) range len(li) len li c[i]|=1<<(li[j]-1) c[i] c i 1<<(li[j]-1) 1 li[j]-1 li[j] li j 1 inf=10**9 inf 10**9 10 9 [inf]*(1<<n) for _ in range(m+1) for _ in range(m+1) _ range(m+1) range m+1 m 1 for _ in range(m+1) [inf]*(1<<n) [inf] inf 1<<n 1 n dp=[[inf]*(1<<n) for _ in range(m+1)] dp [[inf]*(1<<n) for _ in range(m+1)] dp[0][0]=0 dp[0][0] [0] dp 0 0 0 for i in range(1,m+1):
        for j in range(1<<n):
            #i番目の鍵を使わない
            dp[i][j]=min(dp[i-1][j],dp[i][j])

            #i番目の鍵を使う
            dp[i][j|c[i-1]]=min(dp[i][j|c[i-1]],dp[i-1][j]+a[i-1])

     i range(1,m+1) range 1 m+1 m 1 for j in range(1<<n):
            #i番目の鍵を使わない
            dp[i][j]=min(dp[i-1][j],dp[i][j])

            #i番目の鍵を使う
            dp[i][j|c[i-1]]=min(dp[i][j|c[i-1]],dp[i-1][j]+a[i-1])

     j range(1<<n) range 1<<n 1 n dp[i][j]=min(dp[i-1][j],dp[i][j]) dp[i][j] [i] dp i 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][j|c[i-1]]=min(dp[i][j|c[i-1]],dp[i-1][j]+a[i-1]) dp[i][j|c[i-1]] [i] dp i j|c[i-1] j c[i-1] c i-1 i 1 min(dp[i][j|c[i-1]],dp[i-1][j]+a[i-1]) min dp[i][j|c[i-1]] [i] dp i j|c[i-1] j c[i-1] c i-1 i 1 dp[i-1][j]+a[i-1] dp[i-1][j] [i-1] dp i-1 i 1 j a[i-1] a i-1 i 1 ans=dp[m][(1<<n)-1] ans dp[m][(1<<n)-1] [m] dp m (1<<n)-1 1<<n 1 n 1 print(ans if ans<inf else -1) print ans if ans<inf else -1 ans<inf ans inf ans -1 if __name__=="__main__":
    main() __name__=="__main__" __name__ "__main__" main() main def main():
    #入力
    readline=stdin.readline
    n,m=map(int,readline().split())
    a=[0]*m
    b=[0]*m
    c=[0]*m
    for i in range(m):
        a[i],b[i]=map(int,readline().split())
        li=list(map(int,readline().split()))
        for j in range(len(li)):
            c[i]|=1<<(li[j]-1)

    inf=10**9
    dp=[[inf]*(1<<n) for _ in range(m+1)]
    dp[0][0]=0
    for i in range(1,m+1):
        for j in range(1<<n):
            #i番目の鍵を使わない
            dp[i][j]=min(dp[i-1][j],dp[i][j])

            #i番目の鍵を使う
            dp[i][j|c[i-1]]=min(dp[i][j|c[i-1]],dp[i-1][j]+a[i-1])

    ans=dp[m][(1<<n)-1]
    print(ans if ans<inf else -1) def main():
    #入力
    readline=stdin.readline
    n,m=map(int,readline().split())
    a=[0]*m
    b=[0]*m
    c=[0]*m
    for i in range(m):
        a[i],b[i]=map(int,readline().split())
        li=list(map(int,readline().split()))
        for j in range(len(li)):
            c[i]|=1<<(li[j]-1)

    inf=10**9
    dp=[[inf]*(1<<n) for _ in range(m+1)]
    dp[0][0]=0
    for i in range(1,m+1):
        for j in range(1<<n):
            #i番目の鍵を使わない
            dp[i][j]=min(dp[i-1][j],dp[i][j])

            #i番目の鍵を使う
            dp[i][j|c[i-1]]=min(dp[i][j|c[i-1]],dp[i-1][j]+a[i-1])

    ans=dp[m][(1<<n)-1]
    print(ans if ans<inf else -1) main
from sys import stdin
def main():
    #入力
    readline=stdin.readline
    n,m=map(int,readline().split())
    a=[0]*m
    b=[0]*m
    c=[0]*m
    for i in range(m):
        a[i],b[i]=map(int,readline().split())
        li=list(map(int,readline().split()))
        for j in range(len(li)):
            c[i]|=1<<(li[j]-1)

    inf=10**9
    dp=[[inf]*(1<<n) for _ in range(m+1)]
    dp[0][0]=0
    for i in range(1,m+1):
        for j in range(1<<n):
            #i番目の鍵を使わない
            dp[i][j]=min(dp[i-1][j],dp[i][j])

            #i番目の鍵を使う
            dp[i][j|c[i-1]]=min(dp[i][j|c[i-1]],dp[i-1][j]+a[i-1])

    ans=dp[m][(1<<n)-1]
    print(ans if ans<inf else -1)

if __name__=="__main__":
    main()