INF = float("inf")



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



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

dp[0] = 0



for _ in range(M):

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

    C = [int(i) for i in input().split()]

    mask = sum(1 << (c - 1) for c in C)

    for i, dpi in enumerate(dp):

        if dp[i | mask] > dpi + a:

            dp[i | mask] = dpi + a



ans = dp[-1]

print((-1 if ans == INF else ans))

def main():

    INF = float("inf")



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



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

    dp[0] = 0



    for _ in range(M):

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

        C = [int(i) for i in input().split()]

        mask = sum(1 << (c - 1) for c in C)

        for i, dpi in enumerate(dp):

            if dp[i | mask] > dpi + a:

                dp[i | mask] = dpi + a



    ans = dp[-1]

    print((-1 if ans == INF else ans))





if __name__ == '__main__':

    main()

INF = float("inf")
N, M = list(map(int, input().split()))
dp = [INF] * (2**N)
dp[0] = 0
for _ in range(M):
    a, b = list(map(int, input().split()))
    C = [int(i) for i in input().split()]
    mask = sum(1 << (c - 1) for c in C)
    for i, dpi in enumerate(dp):
        if dp[i | mask] > dpi + a:
            dp[i | mask] = dpi + a
ans = dp[-1]
print((-1 if ans == INF else ans))

def main():
    INF = float("inf")
    N, M = list(map(int, input().split()))
    dp = [INF] * (2**N)
    dp[0] = 0
    for _ in range(M):
        a, b = list(map(int, input().split()))
        C = [int(i) for i in input().split()]
        mask = sum(1 << (c - 1) for c in C)
        for i, dpi in enumerate(dp):
            if dp[i | mask] > dpi + a:
                dp[i | mask] = dpi + a
    ans = dp[-1]
    print((-1 if ans == INF else ans))


if __name__ == "__main__":
    main()

-INF = float("inf") -N, M = list(map(int, input().split())) -dp = [INF] * (2**N) -dp[0] = 0 -for _ in range(M): -    a, b = list(map(int, input().split())) -    C = [int(i) for i in input().split()] -    mask = sum(1 << (c - 1) for c in C) -    for i, dpi in enumerate(dp): -        if dp[i | mask] > dpi + a: -            dp[i | mask] = dpi + a -ans = dp[-1] -print((-1 if ans == INF else ans)) +def main(): +    INF = float("inf") +    N, M = list(map(int, input().split())) +    dp = [INF] * (2**N) +    dp[0] = 0 +    for _ in range(M): +        a, b = list(map(int, input().split())) +        C = [int(i) for i in input().split()] +        mask = sum(1 << (c - 1) for c in C) +        for i, dpi in enumerate(dp): +            if dp[i | mask] > dpi + a: +                dp[i | mask] = dpi + a +    ans = dp[-1] +    print((-1 if ans == INF else ans)) + + +if __name__ == "__main__": +    main()