#!/usr/bin/python3
# -*- coding:utf-8 -*-

def main():
  n, m = map(int, input().split())
  la, lb = [], []
  lc = []
  MAX = 10**9
  dp = [MAX] * (2 ** 13)
  dp[0] = 0
  
  for _ in range(m):
    a, b = map(int, input().split())
    la.append(a)
    lb.append(b)
    lc.append(sum([1 << c for c in map(int, input().split())]))
    
  for a, c in zip(la, lc):
    for ic in range(len(dp)):
      dp[c | ic] = min(a + dp[ic], dp[c | ic])
  if dp[2**(n+1)-2] != MAX:
    print(dp[2**(n+1)-2])
  else:
    print(-1)

if __name__=='__main__':
  main()
 def main():
  n, m = map(int, input().split())
  la, lb = [], []
  lc = []
  MAX = 10**9
  dp = [MAX] * (2 ** 13)
  dp[0] = 0
  
  for _ in range(m):
    a, b = map(int, input().split())
    la.append(a)
    lb.append(b)
    lc.append(sum([1 << c for c in map(int, input().split())]))
    
  for a, c in zip(la, lc):
    for ic in range(len(dp)):
      dp[c | ic] = min(a + dp[ic], dp[c | ic])
  if dp[2**(n+1)-2] != MAX:
    print(dp[2**(n+1)-2])
  else:
    print(-1) main n, m = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split m la, lb = [], [] la [] lb [] lc = [] lc [] MAX = 10**9 MAX 10**9 10 9 dp = [MAX] * (2 ** 13) dp [MAX] * (2 ** 13) [MAX] MAX 2 ** 13 2 13 dp[0] = 0 dp[0] dp 0 0 for _ in range(m):
    a, b = map(int, input().split())
    la.append(a)
    lb.append(b)
    lc.append(sum([1 << c for c in map(int, input().split())]))
    
   _ range(m) range m a, b = map(int, input().split()) a map(int, input().split()) map int input().split() ().split () input split b la.append(a) la.append la append a lb.append(b) lb.append lb append b 1 << c for c in map(int, input().split()) for c in map(int, input().split()) c map(int, input().split()) map int input().split() ().split () input split for c in map(int, input().split()) 1 << c 1 c lc.append(sum([1 << c for c in map(int, input().split())])) lc.append lc append sum([1 << c for c in map(int, input().split())]) sum [1 << c for c in map(int, input().split())] for a, c in zip(la, lc):
    for ic in range(len(dp)):
      dp[c | ic] = min(a + dp[ic], dp[c | ic])
   a c zip(la, lc) zip la lc for ic in range(len(dp)):
      dp[c | ic] = min(a + dp[ic], dp[c | ic])
   ic range(len(dp)) range len(dp) len dp dp[c | ic] = min(a + dp[ic], dp[c | ic]) dp[c | ic] dp c | ic c ic min(a + dp[ic], dp[c | ic]) min a + dp[ic] a dp[ic] dp ic dp[c | ic] dp c | ic c ic if dp[2**(n+1)-2] != MAX:
    print(dp[2**(n+1)-2])
  else:
    print(-1) dp[2**(n+1)-2] != MAX dp[2**(n+1)-2] dp 2**(n+1)-2 2**(n+1) 2 n+1 n 1 2 MAX print(dp[2**(n+1)-2]) print dp[2**(n+1)-2] dp 2**(n+1)-2 2**(n+1) 2 n+1 n 1 2 print(-1) print -1 if __name__=='__main__':
  main() __name__=='__main__' __name__ '__main__' main() main def main():
  n, m = map(int, input().split())
  la, lb = [], []
  lc = []
  MAX = 10**9
  dp = [MAX] * (2 ** 13)
  dp[0] = 0
  
  for _ in range(m):
    a, b = map(int, input().split())
    la.append(a)
    lb.append(b)
    lc.append(sum([1 << c for c in map(int, input().split())]))
    
  for a, c in zip(la, lc):
    for ic in range(len(dp)):
      dp[c | ic] = min(a + dp[ic], dp[c | ic])
  if dp[2**(n+1)-2] != MAX:
    print(dp[2**(n+1)-2])
  else:
    print(-1) def main():
  n, m = map(int, input().split())
  la, lb = [], []
  lc = []
  MAX = 10**9
  dp = [MAX] * (2 ** 13)
  dp[0] = 0
  
  for _ in range(m):
    a, b = map(int, input().split())
    la.append(a)
    lb.append(b)
    lc.append(sum([1 << c for c in map(int, input().split())]))
    
  for a, c in zip(la, lc):
    for ic in range(len(dp)):
      dp[c | ic] = min(a + dp[ic], dp[c | ic])
  if dp[2**(n+1)-2] != MAX:
    print(dp[2**(n+1)-2])
  else:
    print(-1) main
#!/usr/bin/python3
# -*- coding:utf-8 -*-

def main():
  n, m = map(int, input().split())
  la, lb = [], []
  lc = []
  MAX = 10**9
  dp = [MAX] * (2 ** 13)
  dp[0] = 0
  
  for _ in range(m):
    a, b = map(int, input().split())
    la.append(a)
    lb.append(b)
    lc.append(sum([1 << c for c in map(int, input().split())]))
    
  for a, c in zip(la, lc):
    for ic in range(len(dp)):
      dp[c | ic] = min(a + dp[ic], dp[c | ic])
  if dp[2**(n+1)-2] != MAX:
    print(dp[2**(n+1)-2])
  else:
    print(-1)

if __name__=='__main__':
  main()

