import sys
input = sys.stdin.readline
def main():
    n,m = map(int,input().split())
    dp = [[10**10 for _ in range(2**n)] for _ in range(m+1)]
    dp[0][0] = 0
    for i in range(m):
        a,b = map(int,input().split())
        c = list(map(int,input().split()))
        S = 0
        for j in range(b):
            x = pow(2,c[j]-1)
            S |= x
        for j in range(2**n):
            dp[i+1][j] = min(dp[i+1][j],dp[i][j])
        for j in range(2**n):
            dp[i+1][j|S] = min(dp[i+1][j|S],dp[i][j]+a)
    if dp[m][2**n-1] == 10**10:
        print(-1)
    else:
        print(dp[m][2**n-1])

if __name__ == "__main__":
    main() import sys sys input = sys.stdin.readline input sys.stdin.readline sys.stdin sys stdin readline def main():
    n,m = map(int,input().split())
    dp = [[10**10 for _ in range(2**n)] for _ in range(m+1)]
    dp[0][0] = 0
    for i in range(m):
        a,b = map(int,input().split())
        c = list(map(int,input().split()))
        S = 0
        for j in range(b):
            x = pow(2,c[j]-1)
            S |= x
        for j in range(2**n):
            dp[i+1][j] = min(dp[i+1][j],dp[i][j])
        for j in range(2**n):
            dp[i+1][j|S] = min(dp[i+1][j|S],dp[i][j]+a)
    if dp[m][2**n-1] == 10**10:
        print(-1)
    else:
        print(dp[m][2**n-1]) main n,m = map(int,input().split()) n map(int,input().split()) map int input().split() ().split () input split m [10**10 for _ in range(2**n)] for _ in range(m+1) for _ in range(m+1) _ range(m+1) range m+1 m 1 for _ in range(m+1) [10**10 for _ in range(2**n)] dp = [[10**10 for _ in range(2**n)] for _ in range(m+1)] dp [[10**10 for _ in range(2**n)] for _ in range(m+1)] dp[0][0] = 0 dp[0][0] [0] dp 0 0 0 for i in range(m):
        a,b = map(int,input().split())
        c = list(map(int,input().split()))
        S = 0
        for j in range(b):
            x = pow(2,c[j]-1)
            S |= x
        for j in range(2**n):
            dp[i+1][j] = min(dp[i+1][j],dp[i][j])
        for j in range(2**n):
            dp[i+1][j|S] = min(dp[i+1][j|S],dp[i][j]+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 c = list(map(int,input().split())) c list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split S = 0 S 0 for j in range(b):
            x = pow(2,c[j]-1)
            S |= x
         j range(b) range b x = pow(2,c[j]-1) x pow(2,c[j]-1) pow 2 c[j]-1 c[j] c j 1 S |= x S x for j in range(2**n):
            dp[i+1][j] = min(dp[i+1][j],dp[i][j])
         j range(2**n) range 2**n 2 n 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 for j in range(2**n):
            dp[i+1][j|S] = min(dp[i+1][j|S],dp[i][j]+a)
     j range(2**n) range 2**n 2 n dp[i+1][j|S] = min(dp[i+1][j|S],dp[i][j]+a) dp[i+1][j|S] [i+1] dp i+1 i 1 j|S j S min(dp[i+1][j|S],dp[i][j]+a) min dp[i+1][j|S] [i+1] dp i+1 i 1 j|S j S dp[i][j]+a dp[i][j] [i] dp i j a if dp[m][2**n-1] == 10**10:
        print(-1)
    else:
        print(dp[m][2**n-1]) dp[m][2**n-1] == 10**10 dp[m][2**n-1] [m] dp m 2**n-1 2**n 2 n 1 10**10 10 10 print(-1) print -1 print(dp[m][2**n-1]) print dp[m][2**n-1] [m] dp m 2**n-1 2**n 2 n 1 if __name__ == "__main__":
    main() __name__ == "__main__" __name__ "__main__" main() main def main():
    n,m = map(int,input().split())
    dp = [[10**10 for _ in range(2**n)] for _ in range(m+1)]
    dp[0][0] = 0
    for i in range(m):
        a,b = map(int,input().split())
        c = list(map(int,input().split()))
        S = 0
        for j in range(b):
            x = pow(2,c[j]-1)
            S |= x
        for j in range(2**n):
            dp[i+1][j] = min(dp[i+1][j],dp[i][j])
        for j in range(2**n):
            dp[i+1][j|S] = min(dp[i+1][j|S],dp[i][j]+a)
    if dp[m][2**n-1] == 10**10:
        print(-1)
    else:
        print(dp[m][2**n-1]) def main():
    n,m = map(int,input().split())
    dp = [[10**10 for _ in range(2**n)] for _ in range(m+1)]
    dp[0][0] = 0
    for i in range(m):
        a,b = map(int,input().split())
        c = list(map(int,input().split()))
        S = 0
        for j in range(b):
            x = pow(2,c[j]-1)
            S |= x
        for j in range(2**n):
            dp[i+1][j] = min(dp[i+1][j],dp[i][j])
        for j in range(2**n):
            dp[i+1][j|S] = min(dp[i+1][j|S],dp[i][j]+a)
    if dp[m][2**n-1] == 10**10:
        print(-1)
    else:
        print(dp[m][2**n-1]) main input = sys.stdin.readline sys.stdin.readline input
import sys
input = sys.stdin.readline
def main():
    n,m = map(int,input().split())
    dp = [[10**10 for _ in range(2**n)] for _ in range(m+1)]
    dp[0][0] = 0
    for i in range(m):
        a,b = map(int,input().split())
        c = list(map(int,input().split()))
        S = 0
        for j in range(b):
            x = pow(2,c[j]-1)
            S |= x
        for j in range(2**n):
            dp[i+1][j] = min(dp[i+1][j],dp[i][j])
        for j in range(2**n):
            dp[i+1][j|S] = min(dp[i+1][j|S],dp[i][j]+a)
    if dp[m][2**n-1] == 10**10:
        print(-1)
    else:
        print(dp[m][2**n-1])

if __name__ == "__main__":
    main()