inf = float('inf')



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



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

dp[0] = 0



for _ in range(m):

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

    c = (int(x) - 1 for x in input().split())



    mask = 0

    for k in c:

        mask |= 1 << k



    for b in range((1 << n) - 1):

        nb = b | mask

        dp[nb] = min(dp[nb], dp[b] + cost)



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

print((-1 if res == inf else res))

def main():

    import sys



    input = sys.stdin.readline



    inf = (10 ** 5) * (10 ** 3)



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



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

    dp[0] = 0



    for _ in range(m):

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

        c = (int(x) - 1 for x in input().split())



        mask = 0

        for k in c:

            mask |= 1 << k



        for b in range((1 << n) - 1):

            if dp[b] == inf:

                continue

            nb = b | mask

            dp[nb] = min(dp[nb], dp[b] + cost)



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

    print((-1 if res == inf else res))





if __name__ == '__main__':

    main()

inf = float("inf")
n, m = list(map(int, input().split()))
dp = [inf] * (1 << n)
dp[0] = 0
for _ in range(m):
    cost, _ = list(map(int, input().split()))
    c = (int(x) - 1 for x in input().split())
    mask = 0
    for k in c:
        mask |= 1 << k
    for b in range((1 << n) - 1):
        nb = b | mask
        dp[nb] = min(dp[nb], dp[b] + cost)
res = dp[(1 << n) - 1]
print((-1 if res == inf else res))

def main():
    import sys

    input = sys.stdin.readline
    inf = (10**5) * (10**3)
    n, m = list(map(int, input().split()))
    dp = [inf] * (1 << n)
    dp[0] = 0
    for _ in range(m):
        cost, _ = list(map(int, input().split()))
        c = (int(x) - 1 for x in input().split())
        mask = 0
        for k in c:
            mask |= 1 << k
        for b in range((1 << n) - 1):
            if dp[b] == inf:
                continue
            nb = b | mask
            dp[nb] = min(dp[nb], dp[b] + cost)
    res = dp[(1 << n) - 1]
    print((-1 if res == inf else res))


if __name__ == "__main__":
    main()

-inf = float("inf") -n, m = list(map(int, input().split())) -dp = [inf] * (1 << n) -dp[0] = 0 -for _ in range(m): -    cost, _ = list(map(int, input().split())) -    c = (int(x) - 1 for x in input().split()) -    mask = 0 -    for k in c: -        mask |= 1 << k -    for b in range((1 << n) - 1): -        nb = b | mask -        dp[nb] = min(dp[nb], dp[b] + cost) -res = dp[(1 << n) - 1] -print((-1 if res == inf else res)) +def main(): +    import sys + +    input = sys.stdin.readline +    inf = (10**5) * (10**3) +    n, m = list(map(int, input().split())) +    dp = [inf] * (1 << n) +    dp[0] = 0 +    for _ in range(m): +        cost, _ = list(map(int, input().split())) +        c = (int(x) - 1 for x in input().split()) +        mask = 0 +        for k in c: +            mask |= 1 << k +        for b in range((1 << n) - 1): +            if dp[b] == inf: +                continue +            nb = b | mask +            dp[nb] = min(dp[nb], dp[b] + cost) +    res = dp[(1 << n) - 1] +    print((-1 if res == inf else res)) + + +if __name__ == "__main__": +    main()