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: Wrong Answer)

#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rand NO_SUCH_THING
#define fi first
#define se second
#define Rep(i,a,b) for(RG int i=(a);i<=int(b);++i)
#define Dep(i,a,b) for(RG int i=(a);i>=int(b);--i)
#define rep(i,a,b) for(RG int i=(a);i<int(b);++i)
#define pc putchar
#define RG register
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define mem(x,v) memset(x,v,sizeof(x))
typedef long double ld;
inline ll read(){
	ll x = 0; char ch = gc(); bool positive = 1;
	for (; !isdigit(ch); ch = gc())	if (ch == '-')	positive = 0;
	for (; isdigit(ch); ch = gc())	x = x * 10 + ch - '0';
	return positive ? x : -x;
}
void write(ll x){if(x<0)x=-x,pc('-');if(x>=10)write(x/10);putchar(x%10+'0');}
void writeln(ll x){write(x);puts("");}
int n,m;
namespace Subtask5{
	#define lowbit(x) (((x) & (-x)))
	int c[100005];
	inline int query(RG int x){RG int ans = 0;for(;x;x-=lowbit(x)) ans+=c[x];return ans;}
	inline void modify(RG int x,RG int v){for(;x<=n;x+=lowbit(x)) c[x]+=v;}
	struct node{
		int l,r,len;
		bool operator < (const node &w) const{
			return len < w.len;
		}
	}a[10000005],tmp[10000005];
	inline void solve(){
		ll ans = 0;
		mem(c,0);
		Rep(i,1,m){
//a[i] . l = n - 100,a[i].r = n;
			a[i] . l = read(),a[i] . r = read();
			a[i] . len = a[i].r - a[i].l + 1; 
		}
		Rep(i,1,m) c[a[i].len]++;
		Rep(i,1,n) c[i]+=c[i-1];
		Dep(i,m,1) tmp[c[a[i].len]--] = a[i];
		Rep(i,1,m) a[i]=tmp[i];
		mem(c,0);
		RG int j = 1;
		Rep(i,1,n){
			for(;j<=m && a[j].len == i;++j)
				modify(a[j].l,1),modify(a[j].r+1,-1);
			RG ll res = m-j+1;
			for(RG int k=i;k<=n;k+=i) res += query(k);
			ans ^= 1ll * res * i;
		}
		writeln(ans);
	}
}

namespace Subtask4{
	struct node{
		int l,r,len;
		bool operator < (const node &w) const{
			return len < w.len;
		}
	}a[1005];
	int sum[10000005];
	void solve(){
		Rep(i,1,m)a[i].l=read(),a[i].r=read();
		Rep(i,1,m)
		Rep(p,1,a[i].r){
			p=a[i].r/(a[i].r/p);
			int mn=max(a[i].r/(p+1)+1,a[i].l%p==0?a[i].l/p:(a[i].l/p+1)),mx=a[i].r/p;
			if (mn<=mx)	++sum[mn],--sum[mx+1];
		}
		ll ans = 0;
		Rep(i,1,n)sum[i]+=sum[i-1];
		Rep(i,1,n)ans^=sum[i]*i;
		writeln(ans);
	}
}

int main(){
	srand((unsigned long long)"Wzp AK NOI2018");
//	freopen("harem.in","r",stdin);
//	freopen("harem.out","w",stdout);
	m = read(),n = read();
//	if(n <= 100000 && m <= 2000000){
	if(m<=1000) Subtask4::solve(); else
				Subtask5::solve();
//	} else
//	if(n<=10000){
//		Subtask3::solve();
//	} else
//		Subtask2::solve();
//	freopen("con","w",stdout);
//	printf("%lf\n",(double)clock());
}
//只要做素数，然后莫比乌斯反演。
//m=1000的怎么搞
/*
如果长度为len,那么1...len是显然会产生1的贡献的。
另外的贡献产生在len+1 …… n

如果长度小于sqrt(n)，直接暴力加，在len+1的开始的时候就暴力加
时间复杂度O(m sqrt(n))
如果长度大于sqrt(n)，
说明只可能对sqrt(n)+1……n这些数产生其它影响
*/


//给你整数n,c,d。现在有整数x1……,xn和b1……,bn，满足0