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

dp = [10**9 for _ in range(2**n)]

dp[0] = 0

for i in range(m):

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

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

    num = 0

    for j in range(b):

        num += 1 << (c[j]-1)

    for s in range(2**n):

        if dp[s|num] >= dp[s] + a:

            dp[s|num] = dp[s] + a

if dp[-1] == 10**9:

    print((-1))

else:

    print((dp[-1]))
def main():

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

    dp = [10**9 for _ in range(2**n)]

    dp[0] = 0

    for i in range(m):

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

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

        num = 0

        for j in range(b):

            num += 1 << (c[j]-1)

        for s in range(2**n):

            if dp[s|num] >= dp[s] + a:

                dp[s|num] = dp[s] + a

    if dp[-1] == 10**9:

        print((-1))

    else:

        print((dp[-1]))

if __name__ == '__main__':

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

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


if __name__ == "__main__":
    main()

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