def main():

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

    inf = 10**9

    bit_dp = [inf for _ in range(2**(n))]

    bit_dp[0] = 0

    for i in range(m):

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

        c = list(map(int, input().split(' ')))

        bit_n = 0

        for i in c:

            bit_n |= 1 << i-1

        for i in range(2**(n)):

            bit_dp[i|bit_n] = min(bit_dp[i|bit_n], bit_dp[i] + a)

    if bit_dp[-1] >= inf:

        print((-1))

    else:

        print((bit_dp[-1]))

if __name__ == '__main__':

    main()
def main():

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

    inf = 10**9

    bit_dp = [inf for _ in range(2**(n))]

    bit_dp[0] = 0

    for i in range(m):

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

        c = list(map(int, input().split(' ')))

        bit_n = 0

        for i in c:

            bit_n |= 1 << i-1

        for i in range(2**(n)):

            if bit_dp[i|bit_n] > bit_dp[i] + a:

                bit_dp[i|bit_n] = bit_dp[i] + a

    if bit_dp[-1] >= inf:

        print((-1))

    else:

        print((bit_dp[-1]))

if __name__ == '__main__':

    main()
def main():
    n, m = list(map(int, input().split(" ")))
    inf = 10**9
    bit_dp = [inf for _ in range(2 ** (n))]
    bit_dp[0] = 0
    for i in range(m):
        a, b = list(map(int, input().split(" ")))
        c = list(map(int, input().split(" ")))
        bit_n = 0
        for i in c:
            bit_n |= 1 << i - 1
        for i in range(2 ** (n)):
            bit_dp[i | bit_n] = min(bit_dp[i | bit_n], bit_dp[i] + a)
    if bit_dp[-1] >= inf:
        print((-1))
    else:
        print((bit_dp[-1]))


if __name__ == "__main__":
    main()

def main():
    n, m = list(map(int, input().split(" ")))
    inf = 10**9
    bit_dp = [inf for _ in range(2 ** (n))]
    bit_dp[0] = 0
    for i in range(m):
        a, b = list(map(int, input().split(" ")))
        c = list(map(int, input().split(" ")))
        bit_n = 0
        for i in c:
            bit_n |= 1 << i - 1
        for i in range(2 ** (n)):
            if bit_dp[i | bit_n] > bit_dp[i] + a:
                bit_dp[i | bit_n] = bit_dp[i] + a
    if bit_dp[-1] >= inf:
        print((-1))
    else:
        print((bit_dp[-1]))


if __name__ == "__main__":
    main()

-            bit_dp[i | bit_n] = min(bit_dp[i | bit_n], bit_dp[i] + a) +            if bit_dp[i | bit_n] > bit_dp[i] + a: +                bit_dp[i | bit_n] = bit_dp[i] + a