def main():
    N, M = map(int, input().split())
    S = []
    for i in range(M):
        a, b = map(int, input().split())
        C = list(map(int, input().split()))
        s = 0
        for c in C:
            c -= 1
            s |= (1 << c)
        S.append((a,s))

    dp = [float('inf')] * (1 << N)
    dp[0] = 0
    for i in range(1 << N):
        for j in range(M):
            t = i | S[j][1]
            dp[t] = min(dp[t], dp[i] + S[j][0])

    if dp[(1<<N)-1] == float('inf'):
        print(-1)
    else:
        print(dp[(1<<N)-1])
    
if __name__ == "__main__":
    main() def main():
    N, M = map(int, input().split())
    S = []
    for i in range(M):
        a, b = map(int, input().split())
        C = list(map(int, input().split()))
        s = 0
        for c in C:
            c -= 1
            s |= (1 << c)
        S.append((a,s))

    dp = [float('inf')] * (1 << N)
    dp[0] = 0
    for i in range(1 << N):
        for j in range(M):
            t = i | S[j][1]
            dp[t] = min(dp[t], dp[i] + S[j][0])

    if dp[(1<<N)-1] == float('inf'):
        print(-1)
    else:
        print(dp[(1<<N)-1])
     main N, M = map(int, input().split()) N map(int, input().split()) map int input().split() ().split () input split M S = [] S [] for i in range(M):
        a, b = map(int, input().split())
        C = list(map(int, input().split()))
        s = 0
        for c in C:
            c -= 1
            s |= (1 << c)
        S.append((a,s))

     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 c in C:
            c -= 1
            s |= (1 << c)
         c C c -= 1 c 1 s |= (1 << c) s 1 << c 1 c S.append((a,s)) S.append S append (a,s) a s dp = [float('inf')] * (1 << N) dp [float('inf')] * (1 << N) [float('inf')] float('inf') float 'inf' 1 << N 1 N dp[0] = 0 dp[0] dp 0 0 for i in range(1 << N):
        for j in range(M):
            t = i | S[j][1]
            dp[t] = min(dp[t], dp[i] + S[j][0])

     i range(1 << N) range 1 << N 1 N for j in range(M):
            t = i | S[j][1]
            dp[t] = min(dp[t], dp[i] + S[j][0])

     j range(M) range M t = i | S[j][1] t i | S[j][1] i S[j][1] [j] S j 1 dp[t] = min(dp[t], dp[i] + S[j][0]) dp[t] dp t min(dp[t], dp[i] + S[j][0]) min dp[t] dp t dp[i] + S[j][0] dp[i] dp i S[j][0] [j] S j 0 if dp[(1<<N)-1] == float('inf'):
        print(-1)
    else:
        print(dp[(1<<N)-1])
     dp[(1<<N)-1] == float('inf') dp[(1<<N)-1] dp (1<<N)-1 1<<N 1 N 1 float('inf') float 'inf' print(-1) print -1 print(dp[(1<<N)-1]) print dp[(1<<N)-1] dp (1<<N)-1 1<<N 1 N 1 if __name__ == "__main__":
    main() __name__ == "__main__" __name__ "__main__" main() main def main():
    N, M = map(int, input().split())
    S = []
    for i in range(M):
        a, b = map(int, input().split())
        C = list(map(int, input().split()))
        s = 0
        for c in C:
            c -= 1
            s |= (1 << c)
        S.append((a,s))

    dp = [float('inf')] * (1 << N)
    dp[0] = 0
    for i in range(1 << N):
        for j in range(M):
            t = i | S[j][1]
            dp[t] = min(dp[t], dp[i] + S[j][0])

    if dp[(1<<N)-1] == float('inf'):
        print(-1)
    else:
        print(dp[(1<<N)-1])
     def main():
    N, M = map(int, input().split())
    S = []
    for i in range(M):
        a, b = map(int, input().split())
        C = list(map(int, input().split()))
        s = 0
        for c in C:
            c -= 1
            s |= (1 << c)
        S.append((a,s))

    dp = [float('inf')] * (1 << N)
    dp[0] = 0
    for i in range(1 << N):
        for j in range(M):
            t = i | S[j][1]
            dp[t] = min(dp[t], dp[i] + S[j][0])

    if dp[(1<<N)-1] == float('inf'):
        print(-1)
    else:
        print(dp[(1<<N)-1])
     main
def main():
    N, M = map(int, input().split())
    S = []
    for i in range(M):
        a, b = map(int, input().split())
        C = list(map(int, input().split()))
        s = 0
        for c in C:
            c -= 1
            s |= (1 << c)
        S.append((a,s))

    dp = [float('inf')] * (1 << N)
    dp[0] = 0
    for i in range(1 << N):
        for j in range(M):
            t = i | S[j][1]
            dp[t] = min(dp[t], dp[i] + S[j][0])

    if dp[(1<<N)-1] == float('inf'):
        print(-1)
    else:
        print(dp[(1<<N)-1])
    
if __name__ == "__main__":
    main()