N, M = map(int,input().split())
dp = [float("inf")]*(2**N)
dp[0] = 0
for i in range(1, M+1):
    a,b = map(int,input().split())
    c = list(map(int,input().split()))
    d = 0
    for j  in range(1, N+1):
        if j in c:
            d += 2**(j-1)
    for j in range(2**N):
        dp[j | d] = min(dp[j | d], dp[j] + a)
print(dp[-1] if dp[-1] != float("inf") else -1) N, M = map(int,input().split()) N map(int,input().split()) map int input().split() ().split () input split M dp = [float("inf")]*(2**N) dp [float("inf")]*(2**N) [float("inf")] float("inf") float "inf" 2**N 2 N dp[0] = 0 dp[0] dp 0 0 for i in range(1, M+1):
    a,b = map(int,input().split())
    c = list(map(int,input().split()))
    d = 0
    for j  in range(1, N+1):
        if j in c:
            d += 2**(j-1)
    for j in range(2**N):
        dp[j | d] = min(dp[j | d], dp[j] + a) i range(1, M+1) range 1 M+1 M 1 a,b = map(int,input().split()) a map(int,input().split()) map int input().split() ().split () input split b c = list(map(int,input().split())) c list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split d = 0 d 0 for j  in range(1, N+1):
        if j in c:
            d += 2**(j-1)
     j range(1, N+1) range 1 N+1 N 1 if j in c:
            d += 2**(j-1)
     j in c j c d += 2**(j-1) d 2**(j-1) 2 j-1 j 1 for j in range(2**N):
        dp[j | d] = min(dp[j | d], dp[j] + a) j range(2**N) range 2**N 2 N dp[j | d] = min(dp[j | d], dp[j] + a) dp[j | d] dp j | d j d min(dp[j | d], dp[j] + a) min dp[j | d] dp j | d j d dp[j] + a dp[j] dp j a print(dp[-1] if dp[-1] != float("inf") else -1) print dp[-1] if dp[-1] != float("inf") else -1 dp[-1] != float("inf") dp[-1] dp -1 float("inf") float "inf" dp[-1] dp -1 -1 b = map(int,input().split()) map(int,input().split()) b d += 2**(j-1) 2**(j-1) d c = list(map(int,input().split())) list(map(int,input().split())) c N, M = map(int,input().split()) map(int,input().split()) N dp = [float("inf")]*(2**N) [float("inf")]*(2**N) dp M = map(int,input().split()) map(int,input().split()) M d = 0 0 d a,b = map(int,input().split()) map(int,input().split()) a
N, M = map(int,input().split())
dp = [float("inf")]*(2**N)
dp[0] = 0
for i in range(1, M+1):
    a,b = map(int,input().split())
    c = list(map(int,input().split()))
    d = 0
    for j  in range(1, N+1):
        if j in c:
            d += 2**(j-1)
    for j in range(2**N):
        dp[j | d] = min(dp[j | d], dp[j] + a)
print(dp[-1] if dp[-1] != float("inf") else -1)