

def main():
    n,m=map(int,input().split())

    L=2**n

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

    for _ in range(m):
        a,b = map(int,input().split())

        c = sum(map(lambda x:2**(int(x)-1), input().split()))
        for i in range(L):
            q = c|i
            cost[q] = min(cost[q], cost[i]+a)
    print(cost[L-1] if cost[L-1]<10**8 else -1)

if __name__ == '__main__':
    main() def main():
    n,m=map(int,input().split())

    L=2**n

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

    for _ in range(m):
        a,b = map(int,input().split())

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

        c = sum(map(lambda x:2**(int(x)-1), input().split()))
        for i in range(L):
            q = c|i
            cost[q] = min(cost[q], cost[i]+a)
     _ range(m) range m a,b = map(int,input().split()) a map(int,input().split()) map int input().split() ().split () input split b c = sum(map(lambda x:2**(int(x)-1), input().split())) c sum(map(lambda x:2**(int(x)-1), input().split())) sum map(lambda x:2**(int(x)-1), input().split()) map lambda x:2**(int(x)-1) 2**(int(x)-1) 2 int(x)-1 int(x) int x 1 x input().split() ().split () input split for i in range(L):
            q = c|i
            cost[q] = min(cost[q], cost[i]+a)
     i range(L) range L q = c|i q c|i c i cost[q] = min(cost[q], cost[i]+a) cost[q] cost q min(cost[q], cost[i]+a) min cost[q] cost q cost[i]+a cost[i] cost i a print(cost[L-1] if cost[L-1]<10**8 else -1) print cost[L-1] if cost[L-1]<10**8 else -1 cost[L-1]<10**8 cost[L-1] cost L-1 L 1 10**8 10 8 cost[L-1] cost L-1 L 1 -1 if __name__ == '__main__':
    main() __name__ == '__main__' __name__ '__main__' main() main def main():
    n,m=map(int,input().split())

    L=2**n

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

    for _ in range(m):
        a,b = map(int,input().split())

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

    L=2**n

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

    for _ in range(m):
        a,b = map(int,input().split())

        c = sum(map(lambda x:2**(int(x)-1), input().split()))
        for i in range(L):
            q = c|i
            cost[q] = min(cost[q], cost[i]+a)
    print(cost[L-1] if cost[L-1]<10**8 else -1) main


def main():
    n,m=map(int,input().split())

    L=2**n

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

    for _ in range(m):
        a,b = map(int,input().split())

        c = sum(map(lambda x:2**(int(x)-1), input().split()))
        for i in range(L):
            q = c|i
            cost[q] = min(cost[q], cost[i]+a)
    print(cost[L-1] if cost[L-1]<10**8 else -1)

if __name__ == '__main__':
    main()
