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