# -*- coding: utf-8 -*-

# if x < y:

#     z = x

# elif True:

#     z = y

# else:

#     z = 100

import sys,os,math

from collections import Counter, defaultdict

import bisect

from sys import stdin, stdout

from itertools import repeat





# n, k = map(int, raw_input().split())

# da = map(int, raw_input().split())

# db = map(int, raw_input().split())



def main():

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

    bf, af = [10000000 for i in range(1<<n)], [10000000 for i in range(1<<n)]

    bf[0] = 0

    for i in range(m):

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

        ad = 0

        for st in map(int, input().split()):

            ad |= 1<<(st-1)

        for st in range(1<<n):

            af[st|ad] = min(bf[st|ad], bf[st]+a, af[st|ad])

            af[st] = min(af[st], bf[st])

        bf, af = af, bf

    if bf[(1<<n)-1] == 10000000:

        print(-1)

    else:

        print(bf[(1<<n)-1])







main()

# -*- coding: utf-8 -*-

# if x < y:

#     z = x

# elif True:

#     z = y

# else:

#     z = 100

import sys,os,math

from collections import Counter, defaultdict

import bisect

from sys import stdin, stdout

from itertools import repeat





# n, k = map(int, raw_input().split())

# da = map(int, raw_input().split())

# db = map(int, raw_input().split())



def main():

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

    bf, af = [10000000 for i in range(1<<n)], [10000000 for i in range(1<<n)]

    bf[0] = 0

    for i in range(m):

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

        ad = 0

        for st in map(int, input().split()):

            ad |= 1<<(st-1)

        for st in range(1<<n):

            af[st|ad] = min(bf[st]+a, af[st|ad])

            af[st] = min(af[st], bf[st])

        bf, af = af, bf

    if bf[(1<<n)-1] == 10000000:

        print(-1)

    else:

        print(bf[(1<<n)-1])





main()

# -*- coding: utf-8 -*-
# if x < y:
#     z = x
# elif True:
#     z = y
# else:
#     z = 100
import sys, os, math
from collections import Counter, defaultdict
import bisect
from sys import stdin, stdout
from itertools import repeat

# n, k = map(int, raw_input().split())
# da = map(int, raw_input().split())
# db = map(int, raw_input().split())
def main():
    n, m = list(map(int, input().split()))
    bf, af = [10000000 for i in range(1 << n)], [10000000 for i in range(1 << n)]
    bf[0] = 0
    for i in range(m):
        a, b = list(map(int, input().split()))
        ad = 0
        for st in map(int, input().split()):
            ad |= 1 << (st - 1)
        for st in range(1 << n):
            af[st | ad] = min(bf[st | ad], bf[st] + a, af[st | ad])
            af[st] = min(af[st], bf[st])
        bf, af = af, bf
    if bf[(1 << n) - 1] == 10000000:
        print(-1)
    else:
        print(bf[(1 << n) - 1])


main()

# -*- coding: utf-8 -*-
# if x < y:
#     z = x
# elif True:
#     z = y
# else:
#     z = 100
import sys, os, math
from collections import Counter, defaultdict
import bisect
from sys import stdin, stdout
from itertools import repeat

# n, k = map(int, raw_input().split())
# da = map(int, raw_input().split())
# db = map(int, raw_input().split())
def main():
    n, m = list(map(int, input().split()))
    bf, af = [10000000 for i in range(1 << n)], [10000000 for i in range(1 << n)]
    bf[0] = 0
    for i in range(m):
        a, b = list(map(int, input().split()))
        ad = 0
        for st in map(int, input().split()):
            ad |= 1 << (st - 1)
        for st in range(1 << n):
            af[st | ad] = min(bf[st] + a, af[st | ad])
            af[st] = min(af[st], bf[st])
        bf, af = af, bf
    if bf[(1 << n) - 1] == 10000000:
        print(-1)
    else:
        print(bf[(1 << n) - 1])


main()

-            af[st | ad] = min(bf[st | ad], bf[st] + a, af[st | ad]) +            af[st | ad] = min(bf[st] + a, af[st | ad])