def main():

    N,M=list(map(int,input().split()))

    L=2**N

    dp=[10**7 for i in range(L)]

    dp[0]=0





    for i in range(M):

        a, _ = list(map(int, input().split()))

        key=sum([2**(int(i)-1) for i in input().split()])

        for j in range(L):

                q=j|key

                dp[q]=min(dp[j]+a,dp[q])





    ans=dp[L-1]

    print((ans if ans<10**7 else -1))



if __name__ == '__main__':

    main()
def main():

    n, m = list(map(int, input().split()))

    p = 2**n

    inf = 10**7

    dp = [inf]*p

    dp[0] = 0

    for _ in range(m):

        a, _ = list(map(int, input().split()))

        c = sum([1<<(int(i)-1) for i in input().split()])

        for s in range(p):

                t = s|c

                new = dp[s] + a

                if dp[t] > new:

                    dp[t] = new

    ans = dp[-1]

    if ans == inf:

        ans = -1

    print(ans)



if __name__ == '__main__':

    main()

def main():
    N, M = list(map(int, input().split()))
    L = 2**N
    dp = [10**7 for i in range(L)]
    dp[0] = 0
    for i in range(M):
        a, _ = list(map(int, input().split()))
        key = sum([2 ** (int(i) - 1) for i in input().split()])
        for j in range(L):
            q = j | key
            dp[q] = min(dp[j] + a, dp[q])
    ans = dp[L - 1]
    print((ans if ans < 10**7 else -1))


if __name__ == "__main__":
    main()

def main():
    n, m = list(map(int, input().split()))
    p = 2**n
    inf = 10**7
    dp = [inf] * p
    dp[0] = 0
    for _ in range(m):
        a, _ = list(map(int, input().split()))
        c = sum([1 << (int(i) - 1) for i in input().split()])
        for s in range(p):
            t = s | c
            new = dp[s] + a
            if dp[t] > new:
                dp[t] = new
    ans = dp[-1]
    if ans == inf:
        ans = -1
    print(ans)


if __name__ == "__main__":
    main()

-    N, M = list(map(int, input().split())) -    L = 2**N -    dp = [10**7 for i in range(L)] +    n, m = list(map(int, input().split())) +    p = 2**n +    inf = 10**7 +    dp = [inf] * p -    for i in range(M): +    for _ in range(m): -        key = sum([2 ** (int(i) - 1) for i in input().split()]) -        for j in range(L): -            q = j | key -            dp[q] = min(dp[j] + a, dp[q]) -    ans = dp[L - 1] -    print((ans if ans < 10**7 else -1)) +        c = sum([1 << (int(i) - 1) for i in input().split()]) +        for s in range(p): +            t = s | c +            new = dp[s] + a +            if dp[t] > new: +                dp[t] = new +    ans = dp[-1] +    if ans == inf: +        ans = -1 +    print(ans)