def main():

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

    p = 2**n

    dp = [float('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

                if dp[t] > dp[s] + a:

                    dp[t] = dp[s] + a

    ans = dp[-1]

    if ans == float('inf'):

        ans = -1

    print(ans)



if __name__ == '__main__':

    main()
def main():

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

    p = 2**n

    dp = [10**7]*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

                if dp[t] > dp[s] + a:

                    dp[t] = dp[s] + a

    ans = dp[-1]

    if ans == 10**7:

        ans = -1

    print(ans)



if __name__ == '__main__':

    main()
def main():
    n, m = list(map(int, input().split()))
    p = 2**n
    dp = [float("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
            if dp[t] > dp[s] + a:
                dp[t] = dp[s] + a
    ans = dp[-1]
    if ans == float("inf"):
        ans = -1
    print(ans)


if __name__ == "__main__":
    main()

def main():
    n, m = list(map(int, input().split()))
    p = 2**n
    dp = [10**7] * 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
            if dp[t] > dp[s] + a:
                dp[t] = dp[s] + a
    ans = dp[-1]
    if ans == 10**7:
        ans = -1
    print(ans)


if __name__ == "__main__":
    main()

-    dp = [float("inf")] * p +    dp = [10**7] * p -    if ans == float("inf"): +    if ans == 10**7: