N, M = map(int, input().split())
newcount = [float('inf') for _ in range(2**N)]
newcount[0] = 0

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 += 2**(c[k]-1)
  count = tuple(newcount)
  for k in range(2**N):
    now = bit|k
    newcount[now] = min(newcount[now], a+count[k])
count = newcount
if count[-1] < 10**6:
  print(count[-1])
else:
  print(-1)
 N, M = map(int, input().split()) N map(int, input().split()) map int input().split() ().split () input split M float('inf') for _ in range(2**N) for _ in range(2**N) _ range(2**N) range 2**N 2 N for _ in range(2**N) float('inf') float 'inf' newcount = [float('inf') for _ in range(2**N)] newcount [float('inf') for _ in range(2**N)] newcount[0] = 0 newcount[0] newcount 0 0 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 += 2**(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 += 2**(c[k]-1)
   k range(b) range b bit += 2**(c[k]-1) bit 2**(c[k]-1) 2 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 count = newcount count newcount if count[-1] < 10**6:
  print(count[-1])
else:
  print(-1) count[-1] < 10**6 count[-1] count -1 10**6 10 6 print(count[-1]) print count[-1] count -1 print(-1) print -1 now = bit|k bit|k now M = map(int, input().split()) map(int, input().split()) M count = newcount newcount count c = list(map(int, input().split())) list(map(int, input().split())) c bit = 0 0 bit N, M = map(int, input().split()) map(int, input().split()) N bit += 2**(c[k]-1) 2**(c[k]-1) bit b = map(int, input().split()) map(int, input().split()) b count = tuple(newcount) tuple(newcount) count newcount = [float('inf') for _ in range(2**N)] [float('inf') for _ in range(2**N)] newcount a, b = map(int, input().split()) map(int, input().split()) a
N, M = map(int, input().split())
newcount = [float('inf') for _ in range(2**N)]
newcount[0] = 0

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 += 2**(c[k]-1)
  count = tuple(newcount)
  for k in range(2**N):
    now = bit|k
    newcount[now] = min(newcount[now], a+count[k])
count = newcount
if count[-1] < 10**6:
  print(count[-1])
else:
  print(-1)

