import sys

input = sys.stdin.readline

sys.setrecursionlimit(100000)



def getN():

    return int(eval(input()))

def getList():

    return list(map(int, input().split()))

import math

from bisect import bisect_left



INF = 10**10

n, m = getList()



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

dp[0] = 0



for i in range(m):

    a, b = getList()

    cnums = getList()

    state = 0

    for cn in cnums:

        state += 1<<(cn-1)

    # print(state)

    for i, d in enumerate(dp):

        nstate = i | state

        # print(i, nstate, state)

        # print(dp[nstate] , dp[state])

        if dp[nstate] > dp[i] + a:

            dp[nstate] = dp[i] + a



# print(dp)

if dp[-1] == INF:

    print((-1))

else:

    print((dp[-1]))
import sys

from collections import defaultdict, deque, Counter

import math

 

# import copy

from bisect import bisect_left, bisect_right

# import heapq

 

# sys.setrecursionlimit(1000000)

 

# input aliases

input = sys.stdin.readline

getS = lambda: input().strip()

getN = lambda: int(eval(input()))

getList = lambda: list(map(int, input().split()))

getZList = lambda: [int(x) - 1 for x in input().split()]

 

INF = 10 ** 20

MOD = 10**9 + 7

divide = lambda x: pow(x, MOD-2, MOD)

 



def makebin(arr):

    ret = 0

    for num in arr:

        ret += 2 ** (num - 1)



    return ret



def main():

    n, m = getList()

    dp = [INF] * (2 ** n)

    dp[0] = 0

    for i in range(m):

        a, b = getList()

        tgt = getList()

        kagi = makebin(tgt)

        for i, d in enumerate(dp):

            if d != -1:

                dp[i|kagi] = min(dp[i|kagi], d + a)

        # print(dp, kagi)



    if dp[-1] == INF:

        print((-1))

        return 

    print((dp[-1]))

    # print(0&1)?













 

if __name__ == "__main__":

    main()

   
import sys

input = sys.stdin.readline
sys.setrecursionlimit(100000)


def getN():
    return int(eval(input()))


def getList():
    return list(map(int, input().split()))


import math
from bisect import bisect_left

INF = 10**10
n, m = getList()
dp = [INF for i in range(1 << n)]
dp[0] = 0
for i in range(m):
    a, b = getList()
    cnums = getList()
    state = 0
    for cn in cnums:
        state += 1 << (cn - 1)
    # print(state)
    for i, d in enumerate(dp):
        nstate = i | state
        # print(i, nstate, state)
        # print(dp[nstate] , dp[state])
        if dp[nstate] > dp[i] + a:
            dp[nstate] = dp[i] + a
# print(dp)
if dp[-1] == INF:
    print((-1))
else:
    print((dp[-1]))

import sys
from collections import defaultdict, deque, Counter
import math

# import copy
from bisect import bisect_left, bisect_right

# import heapq
# sys.setrecursionlimit(1000000)
# input aliases
input = sys.stdin.readline
getS = lambda: input().strip()
getN = lambda: int(eval(input()))
getList = lambda: list(map(int, input().split()))
getZList = lambda: [int(x) - 1 for x in input().split()]
INF = 10**20
MOD = 10**9 + 7
divide = lambda x: pow(x, MOD - 2, MOD)


def makebin(arr):
    ret = 0
    for num in arr:
        ret += 2 ** (num - 1)
    return ret


def main():
    n, m = getList()
    dp = [INF] * (2**n)
    dp[0] = 0
    for i in range(m):
        a, b = getList()
        tgt = getList()
        kagi = makebin(tgt)
        for i, d in enumerate(dp):
            if d != -1:
                dp[i | kagi] = min(dp[i | kagi], d + a)
        # print(dp, kagi)
    if dp[-1] == INF:
        print((-1))
        return
    print((dp[-1]))
    # print(0&1)?


if __name__ == "__main__":
    main()

+from collections import defaultdict, deque, Counter +import math +# import copy +from bisect import bisect_left, bisect_right + +# import heapq +# sys.setrecursionlimit(1000000) +# input aliases -sys.setrecursionlimit(100000) +getS = lambda: input().strip() +getN = lambda: int(eval(input())) +getList = lambda: list(map(int, input().split())) +getZList = lambda: [int(x) - 1 for x in input().split()] +INF = 10**20 +MOD = 10**9 + 7 +divide = lambda x: pow(x, MOD - 2, MOD) -def getN(): -    return int(eval(input())) +def makebin(arr): +    ret = 0 +    for num in arr: +        ret += 2 ** (num - 1) +    return ret -def getList(): -    return list(map(int, input().split())) +def main(): +    n, m = getList() +    dp = [INF] * (2**n) +    dp[0] = 0 +    for i in range(m): +        a, b = getList() +        tgt = getList() +        kagi = makebin(tgt) +        for i, d in enumerate(dp): +            if d != -1: +                dp[i | kagi] = min(dp[i | kagi], d + a) +        # print(dp, kagi) +    if dp[-1] == INF: +        print((-1)) +        return +    print((dp[-1])) +    # print(0&1)? -import math -from bisect import bisect_left - -INF = 10**10 -n, m = getList() -dp = [INF for i in range(1 << n)] -dp[0] = 0 -for i in range(m): -    a, b = getList() -    cnums = getList() -    state = 0 -    for cn in cnums: -        state += 1 << (cn - 1) -    # print(state) -    for i, d in enumerate(dp): -        nstate = i | state -        # print(i, nstate, state) -        # print(dp[nstate] , dp[state]) -        if dp[nstate] > dp[i] + a: -            dp[nstate] = dp[i] + a -# print(dp) -if dp[-1] == INF: -    print((-1)) -else: -    print((dp[-1])) +if __name__ == "__main__": +    main()