#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 