n,m=map(int,input().split())
inf=10**9
cost=[inf for i in range(m)]
for i in range(m):
  a,b=map(int,input().split())
  c=[int(x)-1 for x in input().split()]
  s=0
  for j in c:
    s|=1<<j
  cost[i]=[s,a]
#print(cost)

dp=[inf]*(1<<n)
dp[0]=0
for s in range(1<<n):
  for bit,c in cost:
    dp[s|bit]=min(dp[s|bit], dp[s]+c)
#print(dp)
print(-1 if dp[-1]==inf else dp[-1])
 n,m=map(int,input().split()) n map(int,input().split()) map int input().split() ().split () input split m inf=10**9 inf 10**9 10 9 inf for i in range(m) for i in range(m) i range(m) range m for i in range(m) inf cost=[inf for i in range(m)] cost [inf for i in range(m)] for i in range(m):
  a,b=map(int,input().split())
  c=[int(x)-1 for x in input().split()]
  s=0
  for j in c:
    s|=1<<j
  cost[i]=[s,a]
#print(cost) i range(m) range m a,b=map(int,input().split()) a map(int,input().split()) map int input().split() ().split () input split b int(x)-1 for x in input().split() for x in input().split() x input().split() ().split () input split for x in input().split() int(x)-1 int(x) int x 1 c=[int(x)-1 for x in input().split()] c [int(x)-1 for x in input().split()] s=0 s 0 for j in c:
    s|=1<<j
   j c s|=1<<j s 1<<j 1 j cost[i]=[s,a] cost[i] cost i [s,a] s a dp=[inf]*(1<<n) dp [inf]*(1<<n) [inf] inf 1<<n 1 n dp[0]=0 dp[0] dp 0 0 for s in range(1<<n):
  for bit,c in cost:
    dp[s|bit]=min(dp[s|bit], dp[s]+c)
#print(dp) s range(1<<n) range 1<<n 1 n for bit,c in cost:
    dp[s|bit]=min(dp[s|bit], dp[s]+c)
#print(dp) bit c cost dp[s|bit]=min(dp[s|bit], dp[s]+c) dp[s|bit] dp s|bit s bit min(dp[s|bit], dp[s]+c) min dp[s|bit] dp s|bit s bit dp[s]+c dp[s] dp s c print(-1 if dp[-1]==inf else dp[-1]) print -1 if dp[-1]==inf else dp[-1] dp[-1]==inf dp[-1] dp -1 inf -1 dp[-1] dp -1 s=0 0 s m=map(int,input().split()) map(int,input().split()) m a,b=map(int,input().split()) map(int,input().split()) a s|=1<<j 1<<j s inf=10**9 10**9 inf b=map(int,input().split()) map(int,input().split()) b c=[int(x)-1 for x in input().split()] [int(x)-1 for x in input().split()] c cost=[inf for i in range(m)] [inf for i in range(m)] cost dp=[inf]*(1<<n) [inf]*(1<<n) dp n,m=map(int,input().split()) map(int,input().split()) n
n,m=map(int,input().split())
inf=10**9
cost=[inf for i in range(m)]
for i in range(m):
  a,b=map(int,input().split())
  c=[int(x)-1 for x in input().split()]
  s=0
  for j in c:
    s|=1<<j
  cost[i]=[s,a]
#print(cost)

dp=[inf]*(1<<n)
dp[0]=0
for s in range(1<<n):
  for bit,c in cost:
    dp[s|bit]=min(dp[s|bit], dp[s]+c)
#print(dp)
print(-1 if dp[-1]==inf else dp[-1])

