N, M = map(int, input().split())
newcount = [100000000 for _ in range(2**N)]
newcount[0] = 0
bi = [1,2,4,8,16,32,64,128,256,512,1024,2048]
for k in range(M):
  a, b = map(int, input().split())
  c = list(map(int, input().split()))
  bit = 0
  for k in range(b):
    bit += bi[c[k]-1]
  count = tuple(newcount)
  for k in range(2**N):
    now = bit|k
    newcount[now] = min(newcount[now], a+count[k])
if newcount[-1] < 10**7:
  print(newcount[-1])
else:
  print(-1) N, M = map(int, input().split()) N map(int, input().split()) map int input().split() ().split () input split M 100000000 for _ in range(2**N) for _ in range(2**N) _ range(2**N) range 2**N 2 N for _ in range(2**N) 100000000 newcount = [100000000 for _ in range(2**N)] newcount [100000000 for _ in range(2**N)] newcount[0] = 0 newcount[0] newcount 0 0 bi = [1,2,4,8,16,32,64,128,256,512,1024,2048] bi [1,2,4,8,16,32,64,128,256,512,1024,2048] 1 2 4 8 16 32 64 128 256 512 1024 2048 for k in range(M):
  a, b = map(int, input().split())
  c = list(map(int, input().split()))
  bit = 0
  for k in range(b):
    bit += bi[c[k]-1]
  count = tuple(newcount)
  for k in range(2**N):
    now = bit|k
    newcount[now] = min(newcount[now], a+count[k]) k range(M) range M a, b = map(int, input().split()) a map(int, input().split()) map int input().split() ().split () input split b c = list(map(int, input().split())) c list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split bit = 0 bit 0 for k in range(b):
    bit += bi[c[k]-1]
   k range(b) range b bit += bi[c[k]-1] bit bi[c[k]-1] bi c[k]-1 c[k] c k 1 count = tuple(newcount) count tuple(newcount) tuple newcount for k in range(2**N):
    now = bit|k
    newcount[now] = min(newcount[now], a+count[k]) k range(2**N) range 2**N 2 N now = bit|k now bit|k bit k newcount[now] = min(newcount[now], a+count[k]) newcount[now] newcount now min(newcount[now], a+count[k]) min newcount[now] newcount now a+count[k] a count[k] count k if newcount[-1] < 10**7:
  print(newcount[-1])
else:
  print(-1) newcount[-1] < 10**7 newcount[-1] newcount -1 10**7 10 7 print(newcount[-1]) print newcount[-1] newcount -1 print(-1) print -1 M = map(int, input().split()) map(int, input().split()) M a, b = map(int, input().split()) map(int, input().split()) a b = map(int, input().split()) map(int, input().split()) b c = list(map(int, input().split())) list(map(int, input().split())) c bit = 0 0 bit newcount = [100000000 for _ in range(2**N)] [100000000 for _ in range(2**N)] newcount N, M = map(int, input().split()) map(int, input().split()) N bit += bi[c[k]-1] bi[c[k]-1] bit bi = [1,2,4,8,16,32,64,128,256,512,1024,2048] [1,2,4,8,16,32,64,128,256,512,1024,2048] bi count = tuple(newcount) tuple(newcount) count now = bit|k bit|k now
N, M = map(int, input().split())
newcount = [100000000 for _ in range(2**N)]
newcount[0] = 0
bi = [1,2,4,8,16,32,64,128,256,512,1024,2048]
for k in range(M):
  a, b = map(int, input().split())
  c = list(map(int, input().split()))
  bit = 0
  for k in range(b):
    bit += bi[c[k]-1]
  count = tuple(newcount)
  for k in range(2**N):
    now = bit|k
    newcount[now] = min(newcount[now], a+count[k])
if newcount[-1] < 10**7:
  print(newcount[-1])
else:
  print(-1)