import sys



sys.setrecursionlimit(10 ** 7)

f_inf = float('inf')

mod = 10 ** 9 + 7





def resolve():

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

    ABC = []

    for _ in range(m):

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

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

        s = ["0"] * n

        for c in C:

            s[c - 1] = "1"



        c = "".join(s[::-1])

        ABC.append([a, b, int(c, 2)])



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

    dp[0] = 0

    for a, b, c in ABC:

        for i in range(1 << n):

            idx = i | c

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



    if dp[-1] == f_inf:

        print((-1))

    else:

        print((dp[-1]))





if __name__ == '__main__':

    resolve()

import sys



sys.setrecursionlimit(10 ** 7)

f_inf = float('inf')

mod = 10 ** 9 + 7





def resolve():

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

    ABC = []

    for _ in range(m):

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

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

        bit = ["0"] * n

        for c in C:

            bit[c - 1] = "1"



        bit = "".join(bit)

        ABC.append([a, b, int(bit, 2)])



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

    dp[0] = 0

    for i in range(1 << n):

        for a, b, c in ABC:

            idx = i | c

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



    if dp[-1] != f_inf:

        print((dp[-1]))

    else:

        print((-1))





if __name__ == '__main__':

    resolve()

import sys

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


def resolve():
    n, m = list(map(int, input().split()))
    ABC = []
    for _ in range(m):
        a, b = list(map(int, input().split()))
        C = list(map(int, input().split()))
        s = ["0"] * n
        for c in C:
            s[c - 1] = "1"
        c = "".join(s[::-1])
        ABC.append([a, b, int(c, 2)])
    dp = [f_inf for _ in range(1 << n)]
    dp[0] = 0
    for a, b, c in ABC:
        for i in range(1 << n):
            idx = i | c
            dp[idx] = min(dp[idx], dp[i] + a)
    if dp[-1] == f_inf:
        print((-1))
    else:
        print((dp[-1]))


if __name__ == "__main__":
    resolve()

import sys

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


def resolve():
    n, m = list(map(int, input().split()))
    ABC = []
    for _ in range(m):
        a, b = list(map(int, input().split()))
        C = list(map(int, input().split()))
        bit = ["0"] * n
        for c in C:
            bit[c - 1] = "1"
        bit = "".join(bit)
        ABC.append([a, b, int(bit, 2)])
    dp = [f_inf for _ in range(1 << n)]
    dp[0] = 0
    for i in range(1 << n):
        for a, b, c in ABC:
            idx = i | c
            dp[idx] = min(dp[idx], dp[i] + a)
    if dp[-1] != f_inf:
        print((dp[-1]))
    else:
        print((-1))


if __name__ == "__main__":
    resolve()

-        s = ["0"] * n +        bit = ["0"] * n -            s[c - 1] = "1" -        c = "".join(s[::-1]) -        ABC.append([a, b, int(c, 2)]) +            bit[c - 1] = "1" +        bit = "".join(bit) +        ABC.append([a, b, int(bit, 2)]) -    for a, b, c in ABC: -        for i in range(1 << n): +    for i in range(1 << n): +        for a, b, c in ABC: -    if dp[-1] == f_inf: +    if dp[-1] != f_inf: +        print((dp[-1])) +    else: -    else: -        print((dp[-1]))