from collections import Counter,defaultdict,deque

from heapq import heappop,heappush,heapify

import sys,bisect,math,itertools,fractions,pprint

sys.setrecursionlimit(10**8)

mod = 10**9+7

mod2 = 998244353

INF = float('inf')

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

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

def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))



n,m = inpl()

dp = [[INF]*(2**n) for i in range(m+5)]

for i in range(m+1):

    dp[i][0] = 0

for i in range(m):

    val,b = inpl()

    c = inpl()

    key = 0

    for j in c:

        key += 2**(j-1)

    for j in range(2**n):

        dp[i+1][j] = min(dp[i][j], dp[i][j&(~key)]+val)

        

res = dp[m][2**n-1]

print((res if res != INF else -1))
from collections import Counter,defaultdict,deque

from heapq import heappop,heappush,heapify

import sys,bisect,math,itertools,fractions

from decimal import Decimal

sys.setrecursionlimit(10**8)

mod = 10**9+7

INF = float('inf')

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

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



n,m = inpl()

wv = []

for i in range(m):

    a,b = inpl()

    cnt = 0

    c = inpl()

    for i in c:

        cnt += 1<<(i-1)

    wv.append((a,cnt))

dp = [INF for _ in range(1<<n)]

dp[0] = 0



for i in range(m):

    v,w = wv[i]

    for j in range(1<<n):

        dp[j|w] = min(dp[j|w], dp[j] + v)

print((dp[-1] if dp[-1] != INF else -1))
from collections import Counter, defaultdict, deque
from heapq import heappop, heappush, heapify
import sys, bisect, math, itertools, fractions, pprint

sys.setrecursionlimit(10**8)
mod = 10**9 + 7
mod2 = 998244353
INF = float("inf")


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


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


def inpln(n):
    return list(int(sys.stdin.readline()) for i in range(n))


n, m = inpl()
dp = [[INF] * (2**n) for i in range(m + 5)]
for i in range(m + 1):
    dp[i][0] = 0
for i in range(m):
    val, b = inpl()
    c = inpl()
    key = 0
    for j in c:
        key += 2 ** (j - 1)
    for j in range(2**n):
        dp[i + 1][j] = min(dp[i][j], dp[i][j & (~key)] + val)
res = dp[m][2**n - 1]
print((res if res != INF else -1))

from collections import Counter, defaultdict, deque
from heapq import heappop, heappush, heapify
import sys, bisect, math, itertools, fractions
from decimal import Decimal

sys.setrecursionlimit(10**8)
mod = 10**9 + 7
INF = float("inf")


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


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


n, m = inpl()
wv = []
for i in range(m):
    a, b = inpl()
    cnt = 0
    c = inpl()
    for i in c:
        cnt += 1 << (i - 1)
    wv.append((a, cnt))
dp = [INF for _ in range(1 << n)]
dp[0] = 0
for i in range(m):
    v, w = wv[i]
    for j in range(1 << n):
        dp[j | w] = min(dp[j | w], dp[j] + v)
print((dp[-1] if dp[-1] != INF else -1))

-import sys, bisect, math, itertools, fractions, pprint +import sys, bisect, math, itertools, fractions +from decimal import Decimal -mod2 = 998244353 -def inpln(n): -    return list(int(sys.stdin.readline()) for i in range(n)) - - -dp = [[INF] * (2**n) for i in range(m + 5)] -for i in range(m + 1): -    dp[i][0] = 0 +wv = [] -    val, b = inpl() +    a, b = inpl() +    cnt = 0 -    key = 0 -    for j in c: -        key += 2 ** (j - 1) -    for j in range(2**n): -        dp[i + 1][j] = min(dp[i][j], dp[i][j & (~key)] + val) -res = dp[m][2**n - 1] -print((res if res != INF else -1)) +    for i in c: +        cnt += 1 << (i - 1) +    wv.append((a, cnt)) +dp = [INF for _ in range(1 << n)] +dp[0] = 0 +for i in range(m): +    v, w = wv[i] +    for j in range(1 << n): +        dp[j | w] = min(dp[j | w], dp[j] + v) +print((dp[-1] if dp[-1] != INF else -1))