def main():

    INF = float('inf')

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

    dp = [INF for _ in range(2**N)]

    dp[0] = 0

    for i in range(M):

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

        *C, = list(map(int, input().split()))

        open_bit = 0

        for i in C: open_bit |= 1 << i-1

        for i in range(2**N): dp[i|open_bit] = min(dp[i|open_bit], dp[i] + a)

    print((dp[-1] if dp[-1] != INF else -1))

if __name__ == '__main__':

    main()
INF = float('inf')

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

dp = [INF for _ in range(2**N)]

dp[0] = 0

for i in range(M):

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

    *C, = list(map(int, input().split()))

    open_bit = 0

    for i in C: open_bit |= 1 << i-1

    for i in range(2**N):

        temp = dp[i] + a

        if dp[i|open_bit] > temp: dp[i|open_bit] = temp

print((dp[-1] if dp[-1] != INF else -1))
def main():
    INF = float("inf")
    N, M = list(map(int, input().split()))
    dp = [INF for _ in range(2**N)]
    dp[0] = 0
    for i in range(M):
        a, _ = list(map(int, input().split()))
        (*C,) = list(map(int, input().split()))
        open_bit = 0
        for i in C:
            open_bit |= 1 << i - 1
        for i in range(2**N):
            dp[i | open_bit] = min(dp[i | open_bit], dp[i] + a)
    print((dp[-1] if dp[-1] != INF else -1))


if __name__ == "__main__":
    main()

INF = float("inf")
N, M = list(map(int, input().split()))
dp = [INF for _ in range(2**N)]
dp[0] = 0
for i in range(M):
    a, _ = list(map(int, input().split()))
    (*C,) = list(map(int, input().split()))
    open_bit = 0
    for i in C:
        open_bit |= 1 << i - 1
    for i in range(2**N):
        temp = dp[i] + a
        if dp[i | open_bit] > temp:
            dp[i | open_bit] = temp
print((dp[-1] if dp[-1] != INF else -1))

-def main(): -    INF = float("inf") -    N, M = list(map(int, input().split())) -    dp = [INF for _ in range(2**N)] -    dp[0] = 0 -    for i in range(M): -        a, _ = list(map(int, input().split())) -        (*C,) = list(map(int, input().split())) -        open_bit = 0 -        for i in C: -            open_bit |= 1 << i - 1 -        for i in range(2**N): -            dp[i | open_bit] = min(dp[i | open_bit], dp[i] + a) -    print((dp[-1] if dp[-1] != INF else -1)) - - -if __name__ == "__main__": -    main() +INF = float("inf") +N, M = list(map(int, input().split())) +dp = [INF for _ in range(2**N)] +dp[0] = 0 +for i in range(M): +    a, _ = list(map(int, input().split())) +    (*C,) = list(map(int, input().split())) +    open_bit = 0 +    for i in C: +        open_bit |= 1 << i - 1 +    for i in range(2**N): +        temp = dp[i] + a +        if dp[i | open_bit] > temp: +            dp[i | open_bit] = temp +print((dp[-1] if dp[-1] != INF else -1))