import sys



sys.setrecursionlimit(10 ** 6)

input = sys.stdin.readline



def main():

    inf = 10 ** 9

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

    dp = [inf] * (1 << n)

    dp[0] = 0



    for _ in range(m):

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

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

        mask = 0

        for c in cc:

            mask += 1 << (c - 1)

        for i in range((1 << n) - 1, -1, -1):

            if dp[i] == inf: continue

            ni = i | mask

            if not 0 <= ni < (1 << n): continue

            dp[ni] = min(dp[ni], dp[i] + a)

#        print(dp)

    ans = dp[-1]

    if ans == inf:

        print((-1))

    else:

        print(ans)



main()

from itertools import permutations

import sys



sys.setrecursionlimit(10 ** 6)

from bisect import *

from collections import *

from heapq import *



def II(): return int(sys.stdin.readline())

def MI(): return map(int, sys.stdin.readline().split())

def LI(): return list(map(int, sys.stdin.readline().split()))

def SI(): return sys.stdin.readline()[:-1]

def LLI(rows_number): return [LI() for _ in range(rows_number)]

int1 = lambda x: int(x) - 1

def MI1(): return map(int1, sys.stdin.readline().split())

def LI1(): return list(map(int1, sys.stdin.readline().split()))

p2D = lambda x: print(*x, sep="\n")

dij = [(1, 0), (0, 1), (-1, 0), (0, -1)]



def main():

    inf=10**9

    n,m=MI()

    kk=[]

    aa=[]

    for _ in range(m):

        k=0

        a,b=MI()

        aa.append(a)

        cc=LI1()

        for c in cc:k|=1<<c

        kk.append(k)

    dp=[inf]*(1<<n)

    dp[0]=0

    for bit in range(1<<n):

        pre=dp[bit]

        if pre==inf:continue

        for a,k in zip(aa,kk):

            nb=bit|k

            dp[nb]=min(dp[nb],pre+a)

    ans=dp[-1]

    if ans==inf:print(-1)

    else:print(ans)



main()

import sys

sys.setrecursionlimit(10**6)
input = sys.stdin.readline


def main():
    inf = 10**9
    n, m = list(map(int, input().split()))
    dp = [inf] * (1 << n)
    dp[0] = 0
    for _ in range(m):
        a, b = list(map(int, input().split()))
        cc = list(map(int, input().split()))
        mask = 0
        for c in cc:
            mask += 1 << (c - 1)
        for i in range((1 << n) - 1, -1, -1):
            if dp[i] == inf:
                continue
            ni = i | mask
            if not 0 <= ni < (1 << n):
                continue
            dp[ni] = min(dp[ni], dp[i] + a)
    #        print(dp)
    ans = dp[-1]
    if ans == inf:
        print((-1))
    else:
        print(ans)


main()

from itertools import permutations
import sys

sys.setrecursionlimit(10**6)
from bisect import *
from collections import *
from heapq import *


def II():
    return int(sys.stdin.readline())


def MI():
    return map(int, sys.stdin.readline().split())


def LI():
    return list(map(int, sys.stdin.readline().split()))


def SI():
    return sys.stdin.readline()[:-1]


def LLI(rows_number):
    return [LI() for _ in range(rows_number)]


int1 = lambda x: int(x) - 1


def MI1():
    return map(int1, sys.stdin.readline().split())


def LI1():
    return list(map(int1, sys.stdin.readline().split()))


p2D = lambda x: print(*x, sep="\n")
dij = [(1, 0), (0, 1), (-1, 0), (0, -1)]


def main():
    inf = 10**9
    n, m = MI()
    kk = []
    aa = []
    for _ in range(m):
        k = 0
        a, b = MI()
        aa.append(a)
        cc = LI1()
        for c in cc:
            k |= 1 << c
        kk.append(k)
    dp = [inf] * (1 << n)
    dp[0] = 0
    for bit in range(1 << n):
        pre = dp[bit]
        if pre == inf:
            continue
        for a, k in zip(aa, kk):
            nb = bit | k
            dp[nb] = min(dp[nb], pre + a)
    ans = dp[-1]
    if ans == inf:
        print(-1)
    else:
        print(ans)


main()

+from itertools import permutations -input = sys.stdin.readline +from bisect import * +from collections import * +from heapq import * + + +def II(): +    return int(sys.stdin.readline()) + + +def MI(): +    return map(int, sys.stdin.readline().split()) + + +def LI(): +    return list(map(int, sys.stdin.readline().split())) + + +def SI(): +    return sys.stdin.readline()[:-1] + + +def LLI(rows_number): +    return [LI() for _ in range(rows_number)] + + +int1 = lambda x: int(x) - 1 + + +def MI1(): +    return map(int1, sys.stdin.readline().split()) + + +def LI1(): +    return list(map(int1, sys.stdin.readline().split())) + + +p2D = lambda x: print(*x, sep="\n") +dij = [(1, 0), (0, 1), (-1, 0), (0, -1)] -    n, m = list(map(int, input().split())) +    n, m = MI() +    kk = [] +    aa = [] +    for _ in range(m): +        k = 0 +        a, b = MI() +        aa.append(a) +        cc = LI1() +        for c in cc: +            k |= 1 << c +        kk.append(k) -    for _ in range(m): -        a, b = list(map(int, input().split())) -        cc = list(map(int, input().split())) -        mask = 0 -        for c in cc: -            mask += 1 << (c - 1) -        for i in range((1 << n) - 1, -1, -1): -            if dp[i] == inf: -                continue -            ni = i | mask -            if not 0 <= ni < (1 << n): -                continue -            dp[ni] = min(dp[ni], dp[i] + a) -    #        print(dp) +    for bit in range(1 << n): +        pre = dp[bit] +        if pre == inf: +            continue +        for a, k in zip(aa, kk): +            nb = bit | k +            dp[nb] = min(dp[nb], pre + a) -        print((-1)) +        print(-1)