import sys

input = sys.stdin.readline





def main():

    N, M = list(map(int, input().split()))

    INF = 10 ** 10

    p = 2 ** N

    dp = [INF] * p

    dp[0] = 0



    for _ in range(M):

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

        c = sum([2 ** (i - 1) for i in map(int, input().split())])

        for i in range(p):

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



    if dp[-1] != INF:

        print((dp[-1]))

    else:

        print((-1))





if __name__ == '__main__':

    main()
import sys

input = sys.stdin.readline





def main():

    N, M = list(map(int, input().split()))

    INF = 10 ** 10

    p = 2 ** N

    dp = [INF] * p

    dp[0] = 0



    for _ in range(M):

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

        c = sum([2 ** (i - 1) for i in map(int, input().split())])

        for i in range(p):

            if dp[i | c] > dp[i] + a:

                dp[i | c] = dp[i] + a



    if dp[-1] != INF:

        print((dp[-1]))

    else:

        print((-1))





if __name__ == '__main__':

    main()
import sys

input = sys.stdin.readline


def main():
    N, M = list(map(int, input().split()))
    INF = 10**10
    p = 2**N
    dp = [INF] * p
    dp[0] = 0
    for _ in range(M):
        a, b = list(map(int, input().split()))
        c = sum([2 ** (i - 1) for i in map(int, input().split())])
        for i in range(p):
            dp[i | c] = min(dp[i] + a, dp[i | c])
    if dp[-1] != INF:
        print((dp[-1]))
    else:
        print((-1))


if __name__ == "__main__":
    main()

import sys

input = sys.stdin.readline


def main():
    N, M = list(map(int, input().split()))
    INF = 10**10
    p = 2**N
    dp = [INF] * p
    dp[0] = 0
    for _ in range(M):
        a, b = list(map(int, input().split()))
        c = sum([2 ** (i - 1) for i in map(int, input().split())])
        for i in range(p):
            if dp[i | c] > dp[i] + a:
                dp[i | c] = dp[i] + a
    if dp[-1] != INF:
        print((dp[-1]))
    else:
        print((-1))


if __name__ == "__main__":
    main()

-            dp[i | c] = min(dp[i] + a, dp[i | c]) +            if dp[i | c] > dp[i] + a: +                dp[i | c] = dp[i] + a