def main():

    import math

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

    a=[]

    for i in range(M):

        tmp=list(map(int,input().split()))

        tmpc=list(map(int,input().split()))

        c=0

        for j in range(len(tmpc)):

            c+=2**(tmpc[j]-1)

        tmp[1]=c

        a+=[tmp]





    dp=[[10**10 for j in range(2**N)] for i in range(M)]

    dp[0][0]=0

    dp[0][a[0][1]]=a[0][0]





    for i in range(1,M):

        dp[i]=dp[i-1]

        for j in range(2**N):

            z,p=a[i][0],a[i][1]

            q=j|p

            x=dp[i-1][j]+z

            if dp[i][q]>x: dp[i][q]=x



    ans=dp[M-1][2**N-1]

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



if __name__ == '__main__':

    main()

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

L=2**n

cost=[0]+[10**8 for i in range(L-1)]



for i in range(m):

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

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

    for j in range(L):

        q=j|c

        x=cost[j]+a

        if cost[q]>x:

            cost[q]=x

print((cost[L-1] if cost[L-1]<10**8 else -1))
def main():
    import math

    N, M = list(map(int, input().split()))
    a = []
    for i in range(M):
        tmp = list(map(int, input().split()))
        tmpc = list(map(int, input().split()))
        c = 0
        for j in range(len(tmpc)):
            c += 2 ** (tmpc[j] - 1)
        tmp[1] = c
        a += [tmp]
    dp = [[10**10 for j in range(2**N)] for i in range(M)]
    dp[0][0] = 0
    dp[0][a[0][1]] = a[0][0]
    for i in range(1, M):
        dp[i] = dp[i - 1]
        for j in range(2**N):
            z, p = a[i][0], a[i][1]
            q = j | p
            x = dp[i - 1][j] + z
            if dp[i][q] > x:
                dp[i][q] = x
    ans = dp[M - 1][2**N - 1]
    print((ans if ans < 10**10 else -1))


if __name__ == "__main__":
    main()

n, m = list(map(int, input().split()))
L = 2**n
cost = [0] + [10**8 for i in range(L - 1)]
for i in range(m):
    a, b = list(map(int, input().split()))
    c = sum([2 ** (int(i) - 1) for i in input().split()])
    for j in range(L):
        q = j | c
        x = cost[j] + a
        if cost[q] > x:
            cost[q] = x
print((cost[L - 1] if cost[L - 1] < 10**8 else -1))

-def main(): -    import math - -    N, M = list(map(int, input().split())) -    a = [] -    for i in range(M): -        tmp = list(map(int, input().split())) -        tmpc = list(map(int, input().split())) -        c = 0 -        for j in range(len(tmpc)): -            c += 2 ** (tmpc[j] - 1) -        tmp[1] = c -        a += [tmp] -    dp = [[10**10 for j in range(2**N)] for i in range(M)] -    dp[0][0] = 0 -    dp[0][a[0][1]] = a[0][0] -    for i in range(1, M): -        dp[i] = dp[i - 1] -        for j in range(2**N): -            z, p = a[i][0], a[i][1] -            q = j | p -            x = dp[i - 1][j] + z -            if dp[i][q] > x: -                dp[i][q] = x -    ans = dp[M - 1][2**N - 1] -    print((ans if ans < 10**10 else -1)) - - -if __name__ == "__main__": -    main() +n, m = list(map(int, input().split())) +L = 2**n +cost = [0] + [10**8 for i in range(L - 1)] +for i in range(m): +    a, b = list(map(int, input().split())) +    c = sum([2 ** (int(i) - 1) for i in input().split()]) +    for j in range(L): +        q = j | c +        x = cost[j] + a +        if cost[q] > x: +            cost[q] = x +print((cost[L - 1] if cost[L - 1] < 10**8 else -1))