import sys

import heapq



def solve():

    input = sys.stdin.readline

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

    cost = dict()

    for i in range(2 ** N): cost[i] = -1

    cost[0] = 0

    for i in range(M):

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

        c = [int(c) for c in input().split()]

        bit = 0

        for j in c: bit += 2 ** (j - 1)

        for i in range(2 ** N):

            if cost[i] > -1:

                if cost[i | bit] > -1:

                    cost[i | bit] = min(cost[i | bit], cost[i] + a)

                else: cost[i | bit] = cost[i] + a



    #print(cost)



    print((cost[2 ** N - 1]))

    return 0



if __name__ == "__main__":

    solve()

import sys



def solve():

    input = sys.stdin.readline

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

    Dist = [10 ** 20] * pow(2, N)

    Dist[0] = 0

    for _ in range(M):

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

        C = [int(c) for c in input().split()]

        binaryC = 0

        for c in C: binaryC += pow(2, c-1)

        for j, d in enumerate(Dist):

            if d < 10 ** 20: Dist[j | binaryC] = min(Dist[j | binaryC], Dist[j] + a)

    print((Dist[-1] if Dist[-1] < 10 ** 20 else -1))



    return 0



if __name__ == "__main__":

    solve()
import sys
import heapq


def solve():
    input = sys.stdin.readline
    N, M = list(map(int, input().split()))
    cost = dict()
    for i in range(2**N):
        cost[i] = -1
    cost[0] = 0
    for i in range(M):
        a, b = list(map(int, input().split()))
        c = [int(c) for c in input().split()]
        bit = 0
        for j in c:
            bit += 2 ** (j - 1)
        for i in range(2**N):
            if cost[i] > -1:
                if cost[i | bit] > -1:
                    cost[i | bit] = min(cost[i | bit], cost[i] + a)
                else:
                    cost[i | bit] = cost[i] + a
    # print(cost)
    print((cost[2**N - 1]))
    return 0


if __name__ == "__main__":
    solve()

import sys


def solve():
    input = sys.stdin.readline
    N, M = list(map(int, input().split()))
    Dist = [10**20] * pow(2, N)
    Dist[0] = 0
    for _ in range(M):
        a, b = list(map(int, input().split()))
        C = [int(c) for c in input().split()]
        binaryC = 0
        for c in C:
            binaryC += pow(2, c - 1)
        for j, d in enumerate(Dist):
            if d < 10**20:
                Dist[j | binaryC] = min(Dist[j | binaryC], Dist[j] + a)
    print((Dist[-1] if Dist[-1] < 10**20 else -1))
    return 0


if __name__ == "__main__":
    solve()

-import heapq -    cost = dict() -    for i in range(2**N): -        cost[i] = -1 -    cost[0] = 0 -    for i in range(M): +    Dist = [10**20] * pow(2, N) +    Dist[0] = 0 +    for _ in range(M): -        c = [int(c) for c in input().split()] -        bit = 0 -        for j in c: -            bit += 2 ** (j - 1) -        for i in range(2**N): -            if cost[i] > -1: -                if cost[i | bit] > -1: -                    cost[i | bit] = min(cost[i | bit], cost[i] + a) -                else: -                    cost[i | bit] = cost[i] + a -    # print(cost) -    print((cost[2**N - 1])) +        C = [int(c) for c in input().split()] +        binaryC = 0 +        for c in C: +            binaryC += pow(2, c - 1) +        for j, d in enumerate(Dist): +            if d < 10**20: +                Dist[j | binaryC] = min(Dist[j | binaryC], Dist[j] + a) +    print((Dist[-1] if Dist[-1] < 10**20 else -1))