N, M = map(int, input().split())
key = []
for _ in range(M):
  a, b = map(int, input().split())
  s = 0
  C = list(map(lambda x:int(x)-1, input().split()))
  for c in C:
    s |= 1<<c
  key += [(s, a)]
  
dp = [float('inf')]*(1<<N)
dp[0] = 0
for s in range(1<<N):
  for i in range(M):
    t = s | key[i][0] # 遷移先
    cost = dp[s] + key[i][1]
    dp[t] = min(dp[t], cost)
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 key = [] key [] for _ in range(M):
  a, b = map(int, input().split())
  s = 0
  C = list(map(lambda x:int(x)-1, input().split()))
  for c in C:
    s |= 1<<c
  key += [(s, a)]
   _ range(M) range M a, b = map(int, input().split()) a map(int, input().split()) map int input().split() ().split () input split b s = 0 s 0 C = list(map(lambda x:int(x)-1, input().split())) C list(map(lambda x:int(x)-1, input().split())) list map(lambda x:int(x)-1, input().split()) map lambda x:int(x)-1 int(x)-1 int(x) int x 1 x input().split() ().split () input split for c in C:
    s |= 1<<c
   c C s |= 1<<c s 1<<c 1 c key += [(s, a)] key [(s, a)] (s, a) s a 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 s in range(1<<N):
  for i in range(M):
    t = s | key[i][0] # 遷移先
    cost = dp[s] + key[i][1]
    dp[t] = min(dp[t], cost) s range(1<<N) range 1<<N 1 N for i in range(M):
    t = s | key[i][0] # 遷移先
    cost = dp[s] + key[i][1]
    dp[t] = min(dp[t], cost) i range(M) range M t = s | key[i][0] t s | key[i][0] s key[i][0] [i] key i 0 cost = dp[s] + key[i][1] cost dp[s] + key[i][1] dp[s] dp s key[i][1] [i] key i 1 dp[t] = min(dp[t], cost) dp[t] dp t min(dp[t], cost) min dp[t] dp t cost 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 key = [] [] key key += [(s, a)] [(s, a)] key N, M = map(int, input().split()) map(int, input().split()) N b = map(int, input().split()) map(int, input().split()) b dp = [float('inf')]*(1<<N) [float('inf')]*(1<<N) dp C = list(map(lambda x:int(x)-1, input().split())) list(map(lambda x:int(x)-1, input().split())) C s = 0 0 s s |= 1<<c 1<<c s cost = dp[s] + key[i][1] dp[s] + key[i][1] cost t = s | key[i][0] s | key[i][0] t M = map(int, input().split()) map(int, input().split()) M a, b = map(int, input().split()) map(int, input().split()) a
N, M = map(int, input().split())
key = []
for _ in range(M):
  a, b = map(int, input().split())
  s = 0
  C = list(map(lambda x:int(x)-1, input().split()))
  for c in C:
    s |= 1<<c
  key += [(s, a)]
  
dp = [float('inf')]*(1<<N)
dp[0] = 0
for s in range(1<<N):
  for i in range(M):
    t = s | key[i][0] # 遷移先
    cost = dp[s] + key[i][1]
    dp[t] = min(dp[t], cost)
if dp[-1] == float('inf'):
  print(-1)
else:
  print(dp[-1])




