program get_everything
  implicit none
  integer, parameter :: inf = 1e9
  integer :: n, m, a, b, c(12) = 0, dp(0:2**12) = inf, k, i, j, u
  read(*,*) n, m
  u = 2**n-1
  do i = 1, m
    k = 0
    read(*,*) a, b
    read(*,*) c(1:b)
    do j = 1, b
      k = ibset(k,c(j)-1)
    end do
    dp(k) = min(dp(k),a)
  end do
  do i = 1, u
    do j = 1, i
      dp(or(i,j)) = min(dp(or(i,j)),dp(i)+dp(j))
    end do
  end do
  if (dp(u) == inf) then
    write(*,'(i0)') -1
  else
    write(*,'(i0)') dp(u)
  end if
end program get_everything