def main():

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

    p = 2**n

    inf = 10**7

    dp = [inf]*p

    dp[0] = 0

    for _ in range(m):

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

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

        for s in range(p):

                t = s|c

                new = dp[s] + a

                if dp[t] > new:

                    dp[t] = new

    ans = dp[-1]

    if ans == inf:

        ans = -1

    print(ans)



if __name__ == '__main__':

    main()
def main():

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

    p = 2**n

    inf = 10**7

    dp = [inf]*p

    dp[0] = 0

    for _ in range(m):

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

        c = sum([1<<(int(i)-1) for i in input().split()])

        for s in range(p):

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

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

    ans = dp[-1]

    if ans == inf:

        ans = -1

    print(ans)



if __name__ == '__main__':

    main()
def main():
    n, m = list(map(int, input().split()))
    p = 2**n
    inf = 10**7
    dp = [inf] * p
    dp[0] = 0
    for _ in range(m):
        a, _ = list(map(int, input().split()))
        c = sum([2 ** (int(i) - 1) for i in input().split()])
        for s in range(p):
            t = s | c
            new = dp[s] + a
            if dp[t] > new:
                dp[t] = new
    ans = dp[-1]
    if ans == inf:
        ans = -1
    print(ans)


if __name__ == "__main__":
    main()

def main():
    n, m = list(map(int, input().split()))
    p = 2**n
    inf = 10**7
    dp = [inf] * p
    dp[0] = 0
    for _ in range(m):
        a, _ = list(map(int, input().split()))
        c = sum([1 << (int(i) - 1) for i in input().split()])
        for s in range(p):
            if dp[s | c] > dp[s] + a:
                dp[s | c] = dp[s] + a
    ans = dp[-1]
    if ans == inf:
        ans = -1
    print(ans)


if __name__ == "__main__":
    main()

-        c = sum([2 ** (int(i) - 1) for i in input().split()]) +        c = sum([1 << (int(i) - 1) for i in input().split()]) -            t = s | c -            new = dp[s] + a -            if dp[t] > new: -                dp[t] = new +            if dp[s | c] > dp[s] + a: +                dp[s | c] = dp[s] + a