N, M = map(int, input().split())
bit = [int(1e18) for _ in range(1 << N)]
bit[0] = 0
F = {0}
for _ in range(M):
  a, b = map(int, input().split())
  c = list(map(int, input().split()))
  bas = 0
  for k in range(b):
    c[k] -= 1
    bas += (1 << c[k])
  L = [[j, bit[j]] for j in F]
  for j in L:
    tb = 0
    for k in range(N):
      tb += (((j[0] >> k) & 1) | ((bas >> k) & 1)) << k
    bit[tb] = min(bit[tb], j[1] + a)
    F.add(tb)
if bit[-1] != int(1e18):
  print(bit[-1])
else:
  print(-1) N, M = map(int, input().split()) N map(int, input().split()) map int input().split() ().split () input split M int(1e18) for _ in range(1 << N) for _ in range(1 << N) _ range(1 << N) range 1 << N 1 N for _ in range(1 << N) int(1e18) int 1e18 bit = [int(1e18) for _ in range(1 << N)] bit [int(1e18) for _ in range(1 << N)] bit[0] = 0 bit[0] bit 0 0 F = {0} F {0} for _ in range(M):
  a, b = map(int, input().split())
  c = list(map(int, input().split()))
  bas = 0
  for k in range(b):
    c[k] -= 1
    bas += (1 << c[k])
  L = [[j, bit[j]] for j in F]
  for j in L:
    tb = 0
    for k in range(N):
      tb += (((j[0] >> k) & 1) | ((bas >> k) & 1)) << k
    bit[tb] = min(bit[tb], j[1] + a)
    F.add(tb) _ 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 bas = 0 bas 0 for k in range(b):
    c[k] -= 1
    bas += (1 << c[k])
   k range(b) range b c[k] -= 1 c[k] c k 1 bas += (1 << c[k]) bas 1 << c[k] 1 c[k] c k [j, bit[j]] for j in F for j in F j F for j in F [j, bit[j]] j bit[j] bit j L = [[j, bit[j]] for j in F] L [[j, bit[j]] for j in F] for j in L:
    tb = 0
    for k in range(N):
      tb += (((j[0] >> k) & 1) | ((bas >> k) & 1)) << k
    bit[tb] = min(bit[tb], j[1] + a)
    F.add(tb) j L tb = 0 tb 0 for k in range(N):
      tb += (((j[0] >> k) & 1) | ((bas >> k) & 1)) << k
     k range(N) range N tb += (((j[0] >> k) & 1) | ((bas >> k) & 1)) << k tb (((j[0] >> k) & 1) | ((bas >> k) & 1)) << k ((j[0] >> k) & 1) | ((bas >> k) & 1) (j[0] >> k) & 1 j[0] >> k j[0] j 0 k 1 (bas >> k) & 1 bas >> k bas k 1 k bit[tb] = min(bit[tb], j[1] + a) bit[tb] bit tb min(bit[tb], j[1] + a) min bit[tb] bit tb j[1] + a j[1] j 1 a F.add(tb) F.add F add tb if bit[-1] != int(1e18):
  print(bit[-1])
else:
  print(-1) bit[-1] != int(1e18) bit[-1] bit -1 int(1e18) int 1e18 print(bit[-1]) print bit[-1] bit -1 print(-1) print -1 bit = [int(1e18) for _ in range(1 << N)] [int(1e18) for _ in range(1 << N)] bit M = map(int, input().split()) map(int, input().split()) M F = {0} {0} F bas = 0 0 bas a, b = map(int, input().split()) map(int, input().split()) a c = list(map(int, input().split())) list(map(int, input().split())) c L = [[j, bit[j]] for j in F] [[j, bit[j]] for j in F] L tb += (((j[0] >> k) & 1) | ((bas >> k) & 1)) << k (((j[0] >> k) & 1) | ((bas >> k) & 1)) << k tb bas += (1 << c[k]) 1 << c[k] bas N, M = map(int, input().split()) map(int, input().split()) N tb = 0 0 tb b = map(int, input().split()) map(int, input().split()) b
N, M = map(int, input().split())
bit = [int(1e18) for _ in range(1 << N)]
bit[0] = 0
F = {0}
for _ in range(M):
  a, b = map(int, input().split())
  c = list(map(int, input().split()))
  bas = 0
  for k in range(b):
    c[k] -= 1
    bas += (1 << c[k])
  L = [[j, bit[j]] for j in F]
  for j in L:
    tb = 0
    for k in range(N):
      tb += (((j[0] >> k) & 1) | ((bas >> k) & 1)) << k
    bit[tb] = min(bit[tb], j[1] + a)
    F.add(tb)
if bit[-1] != int(1e18):
  print(bit[-1])
else:
  print(-1)