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 C++14 (GCC 5.4.1) (judge verdict: Time Limit Exceeded)

#include <bits/stdc++.h>
#define mp make_pair
#define mt make_tuple
#define X first
#define Y second
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
#define D double
#define ll long long
#define REP(i,a) for(int i=0;i<a;i++)
#define REP1(i,a,b) for(int i=a;i<b;i++)
#define REP2(i,a,b) for(int i=a;i<=b;i++)
#define RREP(i,a) for(int i=a-1;i>=0;i--)
#define RREP1(i,a,b) for(int i=a;i>b;i--)
#define RREP2(i,a,b) for(int i=a;i>=b;i--)
#define SREP(i,x) for(auto i:x)
#define MS0(x) memset((x),0,sizeof((x)))
#define MS1(x) memset((x),-1,sizeof((x)))
#define MSF(x) memset((x),127,sizeof(x))
#define pb push_back
#define LE(x) (int)((x).size())
#define PII pair<int,int>
#define PLL pair<ll,ll>
#define PDD pair<D,D>
#define im guagua
#define RI(x) x=rit()
#define RII(a,b) a=rit(),b=rit()
#define RIII(a,b,c) a=rit(),b=rit(),c=rit()
#define debug 0
const int INF = 0x7F7F7F7F;
const double EPS = 1e-10 ;
const ll mod7 = 1e9+7;
const ll mod9 = 1e9+9;
using namespace std;
inline ll rit(){
    ll f=0,key=1;
    char c;
    do{
        c=getchar();
        if(c=='-') key=-1;
    }while(c<'0' || c>'9');
    do{
        f=f*10+c-'0';
        c=getchar();
    }while(c>='0' && c<='9');
    return f*key;
}
inline void fprt(D f){
    printf("%.08lf",f);
}
void init(){
}
const int Z = 100005;
int n,m;
int tree[Z*4],tag[Z*4];
void modify(int p,int l,int r,int ql,int qr,int cc){
    // cout<<"modify "<<p<<' '<<l<<' '<<r<<' '<<ql<<' '<<qr<<endl;
    if(l==ql && r==qr){
        tree[p]+=cc;
        return ;
    }
    int mid = (l+r)>>1;
    tag[p] = 1;
    if(qr<=mid) modify(p<<1,l,mid,ql,qr,cc);
    else if(ql>mid) modify(p<<1|1,mid+1,r,ql,qr,cc);
    else{
        modify(p<<1,l,mid,ql,mid,cc);
        modify(p<<1|1,mid+1,r,mid+1,qr,cc);
    }
}
int query(int p,int l,int r,int x){
    if(l==r) return tree[p];
    int mid = (l+r)>>1;
    if(!tag[p]) return tree[p];
    if(x<=mid) return tree[p]+query(p<<1,l,mid,x);
    else return tree[p]+query(p<<1|1,mid+1,r,x);
}
map<PII,int> ccm;
void read(){
    int l,r,t,nl,nr;
    RII(n,m);
    REP(i,n){
        RII(l,r);
        ccm[mp(l,r)]++;
    }
    SREP(f,ccm){
        l = nl = f.X.X;
        r = nr = f.X.Y;
        t = 1;
        nl = l;
        nr = r;
        while(1){
            modify(1,1,m,nl,nr,f.Y);
            if(nl==1) break;
            do{
                t = max(r/(nl-1),(l+(nl-2))/(nl-1));
                // t = r/(nl-1);
                nr = min(r/t,nl-1);
                nl = (l+(t-1))/t;
            }while(nl>nr);
        }
    }
}
void solve(){
    REP2(i,1,m){
        printf("%d\n",query(1,1,m,i));
    }
}
int main(){
    int nn=1;
    // nn=rit();
    while(nn--){
        // while(cin>>n) 
            init(),read(),solve();
    }
    return 0;
}