inf = 10 ** 8 + 10



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



keys = set()



for i in range(m):

    price, _ = list(map(int, input().split()))

    key = 0

    for ind in (int(x) - 1 for x in input().split()):

        key += (1 << ind)

    keys.add((price, key))



dp = [inf] * (1 << n)

dp[0] = 0



for price, key in sorted(keys):

    for mask in range(1 << n):

        dp[mask | key] = min(dp[mask | key], dp[mask] + price)



ans = dp[(1 << n) - 1]

print((ans if ans != inf else -1))

def main():

    import sys



    input = sys.stdin.readline



    inf = 10 ** 8 + 10



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



    size = (1 << n)



    dp = [inf] * size

    dp[0] = 0



    for _ in range(m):

        price, _ = list(map(int, input().split()))

        key = sum(1 << ind for ind in (int(x) - 1 for x in input().split()))

        for mask in range(size):

            dp[mask | key] = min(dp[mask | key], dp[mask] + price)



    ans = dp[size - 1]

    print((ans if ans != inf else -1))





if __name__ == '__main__':

    main()

inf = 10**8 + 10
n, m = list(map(int, input().split()))
keys = set()
for i in range(m):
    price, _ = list(map(int, input().split()))
    key = 0
    for ind in (int(x) - 1 for x in input().split()):
        key += 1 << ind
    keys.add((price, key))
dp = [inf] * (1 << n)
dp[0] = 0
for price, key in sorted(keys):
    for mask in range(1 << n):
        dp[mask | key] = min(dp[mask | key], dp[mask] + price)
ans = dp[(1 << n) - 1]
print((ans if ans != inf else -1))

def main():
    import sys

    input = sys.stdin.readline
    inf = 10**8 + 10
    n, m = list(map(int, input().split()))
    size = 1 << n
    dp = [inf] * size
    dp[0] = 0
    for _ in range(m):
        price, _ = list(map(int, input().split()))
        key = sum(1 << ind for ind in (int(x) - 1 for x in input().split()))
        for mask in range(size):
            dp[mask | key] = min(dp[mask | key], dp[mask] + price)
    ans = dp[size - 1]
    print((ans if ans != inf else -1))


if __name__ == "__main__":
    main()

-inf = 10**8 + 10 -n, m = list(map(int, input().split())) -keys = set() -for i in range(m): -    price, _ = list(map(int, input().split())) -    key = 0 -    for ind in (int(x) - 1 for x in input().split()): -        key += 1 << ind -    keys.add((price, key)) -dp = [inf] * (1 << n) -dp[0] = 0 -for price, key in sorted(keys): -    for mask in range(1 << n): -        dp[mask | key] = min(dp[mask | key], dp[mask] + price) -ans = dp[(1 << n) - 1] -print((ans if ans != inf else -1)) +def main(): +    import sys + +    input = sys.stdin.readline +    inf = 10**8 + 10 +    n, m = list(map(int, input().split())) +    size = 1 << n +    dp = [inf] * size +    dp[0] = 0 +    for _ in range(m): +        price, _ = list(map(int, input().split())) +        key = sum(1 << ind for ind in (int(x) - 1 for x in input().split())) +        for mask in range(size): +            dp[mask | key] = min(dp[mask | key], dp[mask] + price) +    ans = dp[size - 1] +    print((ans if ans != inf else -1)) + + +if __name__ == "__main__": +    main()