import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline

n,m = map(int,readline().split())
c = set()
v = {}
for i in range(m):
  a,b = map(int,readline().split())
  d = list(map(int,readline().split()))
  e = 0
  for j in d:
    e += 2**(j-1)
  if i >= 1:
    s = list(c)
    for k in s:
      if not k|e in c:
        c.add(k|e)
        v[k|e] = a+v[k]
      else:
        v[k|e] = min(v[k|e],a+v[k])
  if not e in c:
    c.add(e)
    v[e] = a
  else:
    v[e] = min(v[e],a)
    
if 2**n-1 in c:
  print(v[2**n-1])
else:
  print(-1) import sys sys read = sys.stdin.buffer.read read sys.stdin.buffer.read sys.stdin.buffer sys.stdin sys stdin buffer read readline = sys.stdin.buffer.readline readline sys.stdin.buffer.readline sys.stdin.buffer sys.stdin sys stdin buffer readline n,m = map(int,readline().split()) n map(int,readline().split()) map int readline().split() ().split () readline split m c = set() c set() set v = {} v {} for i in range(m):
  a,b = map(int,readline().split())
  d = list(map(int,readline().split()))
  e = 0
  for j in d:
    e += 2**(j-1)
  if i >= 1:
    s = list(c)
    for k in s:
      if not k|e in c:
        c.add(k|e)
        v[k|e] = a+v[k]
      else:
        v[k|e] = min(v[k|e],a+v[k])
  if not e in c:
    c.add(e)
    v[e] = a
  else:
    v[e] = min(v[e],a)
     i range(m) range m a,b = map(int,readline().split()) a map(int,readline().split()) map int readline().split() ().split () readline split b d = list(map(int,readline().split())) d list(map(int,readline().split())) list map(int,readline().split()) map int readline().split() ().split () readline split e = 0 e 0 for j in d:
    e += 2**(j-1)
   j d e += 2**(j-1) e 2**(j-1) 2 j-1 j 1 if i >= 1:
    s = list(c)
    for k in s:
      if not k|e in c:
        c.add(k|e)
        v[k|e] = a+v[k]
      else:
        v[k|e] = min(v[k|e],a+v[k])
   i >= 1 i 1 s = list(c) s list(c) list c for k in s:
      if not k|e in c:
        c.add(k|e)
        v[k|e] = a+v[k]
      else:
        v[k|e] = min(v[k|e],a+v[k])
   k s if not k|e in c:
        c.add(k|e)
        v[k|e] = a+v[k]
      else:
        v[k|e] = min(v[k|e],a+v[k])
   not k|e in c k|e in c k|e k e c c.add(k|e) c.add c add k|e k e v[k|e] = a+v[k] v[k|e] v k|e k e a+v[k] a v[k] v k v[k|e] = min(v[k|e],a+v[k]) v[k|e] v k|e k e min(v[k|e],a+v[k]) min v[k|e] v k|e k e a+v[k] a v[k] v k if not e in c:
    c.add(e)
    v[e] = a
  else:
    v[e] = min(v[e],a)
     not e in c e in c e c c.add(e) c.add c add e v[e] = a v[e] v e a v[e] = min(v[e],a) v[e] v e min(v[e],a) min v[e] v e a if 2**n-1 in c:
  print(v[2**n-1])
else:
  print(-1) 2**n-1 in c 2**n-1 2**n 2 n 1 c print(v[2**n-1]) print v[2**n-1] v 2**n-1 2**n 2 n 1 print(-1) print -1 v = {} {} v c = set() set() c e += 2**(j-1) 2**(j-1) e d = list(map(int,readline().split())) list(map(int,readline().split())) d s = list(c) list(c) s m = map(int,readline().split()) map(int,readline().split()) m read = sys.stdin.buffer.read sys.stdin.buffer.read read a,b = map(int,readline().split()) map(int,readline().split()) a n,m = map(int,readline().split()) map(int,readline().split()) n b = map(int,readline().split()) map(int,readline().split()) b readline = sys.stdin.buffer.readline sys.stdin.buffer.readline readline e = 0 0 e
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline

n,m = map(int,readline().split())
c = set()
v = {}
for i in range(m):
  a,b = map(int,readline().split())
  d = list(map(int,readline().split()))
  e = 0
  for j in d:
    e += 2**(j-1)
  if i >= 1:
    s = list(c)
    for k in s:
      if not k|e in c:
        c.add(k|e)
        v[k|e] = a+v[k]
      else:
        v[k|e] = min(v[k|e],a+v[k])
  if not e in c:
    c.add(e)
    v[e] = a
  else:
    v[e] = min(v[e],a)
    
if 2**n-1 in c:
  print(v[2**n-1])
else:
  print(-1)
