integer N,M
integer a,b
integer,allocatable::reader(:)
integer key
integer,allocatable::bitDP(:)
read*,N,M
allocate(bitDP(0:2**N-1))
bitDP=10**9
bitDP(0)=0
do i=1,M
  read*,a,b
  allocate(reader(b))
  read*,reader
  key=0
  do j=1,b
    key=IBSET(key,reader(j)-1)
  end do
  do j=0,2**N-1
    bitDP( or(j,key) )=min(bitDP( or(j,key) ), bitDP(j)+a)
  end do
  deallocate(reader)
end do

if(bitDP(2**N-1)==10**9)then
  print"(i0)",-1
else
  print"(i0)",bitDP(2**N-1)
endif

end