Problem:
Score : 700 points

Problem Statement

Snuke has decided to play a game, where the player runs a railway company.
There are M+1 stations on Snuke Line, numbered 0 through M.
A train on Snuke Line stops at station 0 and every d-th station thereafter, where d is a predetermined constant for each train.
For example, if d = 3, the train stops at station 0, 3, 6, 9, and so forth.

There are N kinds of souvenirs sold in areas around Snuke Line. The i-th kind of souvenirs can be purchased when the train stops at one of the following stations: stations l_i, l_i+1, l_i+2, ..., r_i.

There are M values of d, the interval between two stops, for trains on Snuke Line: 1, 2, 3, ..., M.
For each of these M values, find the number of the kinds of souvenirs that can be purchased if one takes a train with that value of d at station 0.
Here, assume that it is not allowed to change trains.

Constraints

1 ≦ N ≦ 3 × 10^{5}

1 ≦ M ≦ 10^{5}

1 ≦ l_i ≦ r_i ≦ M

Input

The input is given from Standard Input in the following format:

N M
l_1 r_1
:
l_{N} r_{N}

Output

Print the answer in M lines. The i-th line should contain the maximum number of the kinds of souvenirs that can be purchased if one takes a train stopping every i-th station.

Sample Input 1

3 3
1 2
2 3
3 3

Sample Output 1

3
2
2

If one takes a train stopping every station, three kinds of souvenirs can be purchased: kind 1, 2 and 3.

If one takes a train stopping every second station, two kinds of souvenirs can be purchased: kind 1 and 2.

If one takes a train stopping every third station, two kinds of souvenirs can be purchased: kind 2 and 3.

Sample Input 2

7 9
1 7
5 9
5 7
5 9
1 1
6 8
3 4

Sample Output 2

7
6
6
5
4
5
5
3
2

Solution in Fortran (gfortran v4.8.4) (judge verdict: Accepted)

module mod_binary_indexed_tree
  implicit none
  type fenwick_tree
    integer :: n
    integer, pointer :: arr(:)
  end type fenwick_tree
  private
  public :: fenwick_tree, init_bit, release_bit
  public :: add, summate, update, maximum
contains
  subroutine init_bit(bit,n)
    implicit none
    type(fenwick_tree) :: bit
    integer, intent(in) :: n
    bit%n = n
    allocate(bit%arr(n))
    bit%arr = 0
    return
  end subroutine init_bit
  subroutine release_bit(bit)
    implicit none
    type(fenwick_tree) :: bit
    if (associated(bit%arr)) deallocate(bit%arr)
    return
  end subroutine release_bit
  subroutine add(bit,i,v)
    implicit none
    type(fenwick_tree) :: bit
    integer, intent(in) :: i, v
    integer :: x
    if (i.eq.0) return
    x = i
    do while (x.le.bit%n)
      bit%arr(x) = bit%arr(x)+v
      x = x+and(x,-x)
    end do
    return
  end subroutine add
  function summate(bit,i) result(s)
    implicit none
    type(fenwick_tree) :: bit
    integer, intent(in) :: i
    integer :: x, s
    x = i
    s = 0
    do while (x.gt.0)
      s = s+bit%arr(x)
      x = x-and(x,-x)
    end do
    return
  end function summate
  subroutine update(bit,i,v)
    implicit none
    type(fenwick_tree) :: bit
    integer, intent(in) :: i, v
    integer :: x
    x = i
    do while (x.le.bit%n)
      if (bit%arr(x).lt.v) bit%arr(x) = v
      x = x+and(x,-x)
    end do
    return
  end subroutine update
  function maximum(bit,i) result(m)
    implicit none
    type(fenwick_tree) :: bit
    integer, intent(in) :: i
    integer :: x, m
    x = i
    m = 0
    do while (x.gt.0)
      m = max(m,bit%arr(x))
      x = x-and(x,-x)
    end do
    return
  end function maximum
end module mod_binary_indexed_tree
program snuke_line
  use mod_binary_indexed_tree
  implicit none
  type(fenwick_tree) :: bit
  integer :: n, m, a(300000,3), ans(100000), i, j, k, x
  a = 0
  ans = 0
  read(*,*) n, m
  do i = 1, n
    read(*,*) a(i,1), a(i,2)
    a(i,3) = a(i,2)-a(i,1)+1
  end do
  call quick_sort(a(1:n,1:3),3)
  call init_bit(bit,m+1)
  ans(1) = n
  j = 1
  do i = 2, m
    do while (j.le.n)
      if (a(j,3).gt.i) exit
      call add(bit,a(j,1),1)
      call add(bit,a(j,2)+1,-1)
      j = j+1
    end do
    x = n-j+1
    do k = i, m, i
      x = x+summate(bit,k)
    end do
    ans(i) = x
  end do
  do i = 1, m
    write(*,'(i0)') ans(i)
  end do
  stop
contains
  recursive subroutine quick_sort(a,i)
    implicit none
    integer, intent(inout) :: a(:,:)
    integer, intent(in) :: i
    integer :: p, c(size(a(1,:)))
    integer :: n, l, r, m
    n = size(a(:,1))
    l = 1
    r = n
    m = (l+r)/2
    p = a(l,i)+a(m,i)+a(r,i)-max(a(l,i),a(m,i),a(r,i))-min(a(l,i),a(m,i),a(r,i))
    do
      do while (a(l,i).lt.p)
        l = l+1
      end do
      do while (a(r,i).gt.p)
        r = r-1
      end do
      if (l.ge.r) exit
      c = a(l,:)
      a(l,:) = a(r,:)
      a(r,:) = c
      l = l+1
      r = r-1
    end do
    if (l.gt.2) call quick_sort(a(1:l-1,:),i)
    if (n.gt.r+1) call quick_sort(a(r+1:n,:),i)
    return
  end subroutine quick_sort
end program snuke_line