n, m = map(int, input().split())
dp = [float("INF")]*(1<<n)
dp[0] = 0
for _ in range(m):
    a, b = map(int, input().split())
    c = list(map(int, input().split()))
    C = 0
    for e in c:
        C += 1<<(e-1)
    for i in range(1<<n): 
        dp[i|C] = min(dp[i|C], dp[i]+a)
if dp[-1] == float("INF"): print(-1)
else: print(dp[-1]) n, m = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split m dp = [float("INF")]*(1<<n) dp [float("INF")]*(1<<n) [float("INF")] float("INF") float "INF" 1<<n 1 n dp[0] = 0 dp[0] dp 0 0 for _ in range(m):
    a, b = map(int, input().split())
    c = list(map(int, input().split()))
    C = 0
    for e in c:
        C += 1<<(e-1)
    for i in range(1<<n): 
        dp[i|C] = min(dp[i|C], dp[i]+a) _ range(m) range m 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 C = 0 C 0 for e in c:
        C += 1<<(e-1)
     e c C += 1<<(e-1) C 1<<(e-1) 1 e-1 e 1 for i in range(1<<n): 
        dp[i|C] = min(dp[i|C], dp[i]+a) i range(1<<n) range 1<<n 1 n dp[i|C] = min(dp[i|C], dp[i]+a) dp[i|C] dp i|C i C min(dp[i|C], dp[i]+a) min dp[i|C] dp i|C i C dp[i]+a dp[i] dp i a if dp[-1] == float("INF"): print(-1)
else: print(dp[-1]) dp[-1] == float("INF") dp[-1] dp -1 float("INF") float "INF" c = list(map(int, input().split())) list(map(int, input().split())) c a, b = map(int, input().split()) map(int, input().split()) a C = 0 0 C C += 1<<(e-1) 1<<(e-1) C b = map(int, input().split()) map(int, input().split()) b dp = [float("INF")]*(1<<n) [float("INF")]*(1<<n) dp n, m = map(int, input().split()) map(int, input().split()) n m = map(int, input().split()) map(int, input().split()) m
n, m = map(int, input().split())
dp = [float("INF")]*(1<<n)
dp[0] = 0
for _ in range(m):
    a, b = map(int, input().split())
    c = list(map(int, input().split()))
    C = 0
    for e in c:
        C += 1<<(e-1)
    for i in range(1<<n): 
        dp[i|C] = min(dp[i|C], dp[i]+a)
if dp[-1] == float("INF"): print(-1)
else: print(dp[-1])