n,m=map(int,input().split())
dp=[10**20]*(1<<n)
dp[0]=0
for i in range(m):
    a,b=map(int,input().split())
    c=list(map(int,input().split()))
    bit=0
    for j in c:bit|=1<<(j-1)
    for j in range(1<<n):
        dp[j|bit]=min(dp[j|bit],dp[j]+a)
if dp[-1]==10**20: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=[10**20]*(1<<n) dp [10**20]*(1<<n) [10**20] 10**20 10 20 1<<n 1 n dp[0]=0 dp[0] dp 0 0 for i in range(m):
    a,b=map(int,input().split())
    c=list(map(int,input().split()))
    bit=0
    for j in c:bit|=1<<(j-1)
    for j in range(1<<n):
        dp[j|bit]=min(dp[j|bit],dp[j]+a) i 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 bit=0 bit 0 for j in c:bit|=1<<(j-1)
     j c for j in range(1<<n):
        dp[j|bit]=min(dp[j|bit],dp[j]+a) j range(1<<n) range 1<<n 1 n dp[j|bit]=min(dp[j|bit],dp[j]+a) dp[j|bit] dp j|bit j bit min(dp[j|bit],dp[j]+a) min dp[j|bit] dp j|bit j bit dp[j]+a dp[j] dp j a if dp[-1]==10**20:print(-1)
else:print(dp[-1]) dp[-1]==10**20 dp[-1] dp -1 10**20 10 20 n,m=map(int,input().split()) map(int,input().split()) n b=map(int,input().split()) map(int,input().split()) b m=map(int,input().split()) map(int,input().split()) m a,b=map(int,input().split()) map(int,input().split()) a dp=[10**20]*(1<<n) [10**20]*(1<<n) dp bit=0 0 bit c=list(map(int,input().split())) list(map(int,input().split())) c
n,m=map(int,input().split())
dp=[10**20]*(1<<n)
dp[0]=0
for i in range(m):
    a,b=map(int,input().split())
    c=list(map(int,input().split()))
    bit=0
    for j in c:bit|=1<<(j-1)
    for j in range(1<<n):
        dp[j|bit]=min(dp[j|bit],dp[j]+a)
if dp[-1]==10**20:print(-1)
else:print(dp[-1])