def read_key():

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

    m = 0

    for c in map(int, input().split()):

        m |= 1 << (c - 1)

    return (a, m)





def main():

    INF = float('inf')



    N, M = list(map(int, input().split()))

    keys = [read_key() for _ in range(M)]



    dp = [[INF] * (1 << N) for _ in range(M + 1)]



    dp[0][0] = 0

    for i in range(M):

        a, m = keys[i]

        dpi = dp[i]

        dpi1 = dp[i + 1]

        for j in range(1 << N):

            if dpi[j] == INF:

                continue

            if dpi[j] + a < dpi1[j | m]:

                dpi1[j | m] = dpi[j] + a

            if dpi[j] < dpi1[j]:

                dpi1[j] = dpi[j]



    if dp[M][(1 << N) - 1] == INF:

        print((-1))

    else:

        print((dp[M][(1 << N) - 1]))





main()

def read_key():

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

    m = 0

    for c in map(int, input().split()):

        m |= 1 << (c - 1)

    return (a, m)





INF = float('inf')



N, M = list(map(int, input().split()))

keys = [read_key() for _ in range(M)]



dp = [INF] * (1 << N)



dp[0] = 0

for i in range(M):

    a, m = keys[i]

    for j in range((1 << N)-1, -1, -1):

        if dp[j] == INF:

            continue

        if dp[j] + a < dp[j | m]:

            dp[j | m] = dp[j] + a



if dp[(1 << N) - 1] == INF:

    print((-1))

else:

    print((dp[(1 << N) - 1]))

def read_key():
    a, _ = list(map(int, input().split()))
    m = 0
    for c in map(int, input().split()):
        m |= 1 << (c - 1)
    return (a, m)


def main():
    INF = float("inf")
    N, M = list(map(int, input().split()))
    keys = [read_key() for _ in range(M)]
    dp = [[INF] * (1 << N) for _ in range(M + 1)]
    dp[0][0] = 0
    for i in range(M):
        a, m = keys[i]
        dpi = dp[i]
        dpi1 = dp[i + 1]
        for j in range(1 << N):
            if dpi[j] == INF:
                continue
            if dpi[j] + a < dpi1[j | m]:
                dpi1[j | m] = dpi[j] + a
            if dpi[j] < dpi1[j]:
                dpi1[j] = dpi[j]
    if dp[M][(1 << N) - 1] == INF:
        print((-1))
    else:
        print((dp[M][(1 << N) - 1]))


main()

def read_key():
    a, _ = list(map(int, input().split()))
    m = 0
    for c in map(int, input().split()):
        m |= 1 << (c - 1)
    return (a, m)


INF = float("inf")
N, M = list(map(int, input().split()))
keys = [read_key() for _ in range(M)]
dp = [INF] * (1 << N)
dp[0] = 0
for i in range(M):
    a, m = keys[i]
    for j in range((1 << N) - 1, -1, -1):
        if dp[j] == INF:
            continue
        if dp[j] + a < dp[j | m]:
            dp[j | m] = dp[j] + a
if dp[(1 << N) - 1] == INF:
    print((-1))
else:
    print((dp[(1 << N) - 1]))

-def main(): -    INF = float("inf") -    N, M = list(map(int, input().split())) -    keys = [read_key() for _ in range(M)] -    dp = [[INF] * (1 << N) for _ in range(M + 1)] -    dp[0][0] = 0 -    for i in range(M): -        a, m = keys[i] -        dpi = dp[i] -        dpi1 = dp[i + 1] -        for j in range(1 << N): -            if dpi[j] == INF: -                continue -            if dpi[j] + a < dpi1[j | m]: -                dpi1[j | m] = dpi[j] + a -            if dpi[j] < dpi1[j]: -                dpi1[j] = dpi[j] -    if dp[M][(1 << N) - 1] == INF: -        print((-1)) -    else: -        print((dp[M][(1 << N) - 1])) - - -main() +INF = float("inf") +N, M = list(map(int, input().split())) +keys = [read_key() for _ in range(M)] +dp = [INF] * (1 << N) +dp[0] = 0 +for i in range(M): +    a, m = keys[i] +    for j in range((1 << N) - 1, -1, -1): +        if dp[j] == INF: +            continue +        if dp[j] + a < dp[j | m]: +            dp[j | m] = dp[j] + a +if dp[(1 << N) - 1] == INF: +    print((-1)) +else: +    print((dp[(1 << N) - 1]))