n,m=map(int,input().split())
k=[]
for i in range(m):
  a,b=map(int,input().split())
  c=sum(map(lambda x:2**(int(x)-1),input().split()))
  k.append((a,c))

dp=[2**100 for i in range(2**n)]
dp[0]=0
for i in k:
  for j in range(2**n):
    dp[i[1]|j]=min(dp[i[1]|j],dp[j]+i[0])
if dp[-1]==2**100:
  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 k=[] k [] for i in range(m):
  a,b=map(int,input().split())
  c=sum(map(lambda x:2**(int(x)-1),input().split()))
  k.append((a,c)) 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=sum(map(lambda x:2**(int(x)-1),input().split())) c sum(map(lambda x:2**(int(x)-1),input().split())) sum map(lambda x:2**(int(x)-1),input().split()) map lambda x:2**(int(x)-1) 2**(int(x)-1) 2 int(x)-1 int(x) int x 1 x input().split() ().split () input split k.append((a,c)) k.append k append (a,c) a c 2**100 for i in range(2**n) for i in range(2**n) i range(2**n) range 2**n 2 n for i in range(2**n) 2**100 2 100 dp=[2**100 for i in range(2**n)] dp [2**100 for i in range(2**n)] dp[0]=0 dp[0] dp 0 0 for i in k:
  for j in range(2**n):
    dp[i[1]|j]=min(dp[i[1]|j],dp[j]+i[0]) i k for j in range(2**n):
    dp[i[1]|j]=min(dp[i[1]|j],dp[j]+i[0]) j range(2**n) range 2**n 2 n dp[i[1]|j]=min(dp[i[1]|j],dp[j]+i[0]) dp[i[1]|j] dp i[1]|j i[1] i 1 j min(dp[i[1]|j],dp[j]+i[0]) min dp[i[1]|j] dp i[1]|j i[1] i 1 j dp[j]+i[0] dp[j] dp j i[0] i 0 if dp[-1]==2**100:
  print(-1)
else:
  print(dp[-1]) dp[-1]==2**100 dp[-1] dp -1 2**100 2 100 print(-1) print -1 print(dp[-1]) print dp[-1] dp -1 n,m=map(int,input().split()) map(int,input().split()) n b=map(int,input().split()) map(int,input().split()) b a,b=map(int,input().split()) map(int,input().split()) a m=map(int,input().split()) map(int,input().split()) m c=sum(map(lambda x:2**(int(x)-1),input().split())) sum(map(lambda x:2**(int(x)-1),input().split())) c dp=[2**100 for i in range(2**n)] [2**100 for i in range(2**n)] dp k=[] [] k
n,m=map(int,input().split())
k=[]
for i in range(m):
  a,b=map(int,input().split())
  c=sum(map(lambda x:2**(int(x)-1),input().split()))
  k.append((a,c))

dp=[2**100 for i in range(2**n)]
dp[0]=0
for i in k:
  for j in range(2**n):
    dp[i[1]|j]=min(dp[i[1]|j],dp[j]+i[0])
if dp[-1]==2**100:
  print(-1)
else:
  print(dp[-1])