#include<bits/stdc++.h>
using namespace std;
#define file "harem"
typedef long long ll;
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 getchar gc//最后要修改，不修改会导致读入速度降低
inline int read(){
	int 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;
}
const int maxn=10000002;
int ans[maxn];
struct query{
	int l,r;
	bool operator <(const query& rhs)const{
		return r-l<rhs.r-rhs.l;
	}
}q[maxn],w[maxn];
int sum[100002];
struct bit{
	int n;
	int a[100002];
	void add(int p,int v){
		for(;p<=n;p+=p&-p)
			a[p]+=v;
	}
	int query(int p){
		int ans=0;
		for(;p;p-=p&-p)
			ans+=a[p];
		return ans;
	}
}b;
int main(){
	//freopen(file".in","r",stdin);
	//freopen(file".out","w",stdout);
	int m=read(),n=read();
	if (m<=10000){
		while(m--){
			int l=read()-1,r=read();
			int nxt;
			for(int i=1;i<=l;i=nxt+1){
				nxt=min(l/(l/i),r/(r/i));
				if (l/i!=r/i)
					ans[i]++,ans[nxt+1]--;
			}
			//(l,r]
			ans[l+1]++,ans[r+1]--;
		}
		ll qwq=0;
		for(int i=1;i<=n;i++){
			ans[i]+=ans[i-1];
			//printf("%d ",ans[i]);
			qwq^=1LL*i*ans[i];
		}
		printf("%lld",qwq);
		return 0;
	}
	for(int i=1;i<=m;i++){
		w[i].l=read(),w[i].r=read();
		sum[w[i].r-w[i].l]++;
	}
	for(int i=1;i<=n;i++)
		sum[i]+=sum[i-1];
	for(int i=1;i<=m;i++)
		q[sum[w[i].r-w[i].l]--]=w[i];
	b.n=n;
	int j=1;
	ll sum=0;
	for(int i=1;i<=n;i++){
		while(j<=m && q[j].r-q[j].l<i){
			b.add(q[j].l,1);
			b.add(q[j].r+1,-1);
			j++;
		}
		ll now=m-j+1;
		for(int j=i;j<=n;j+=i)
			now+=b.query(j);
		sum^=1LL*i*now;
	}
	printf("%lld",sum);
}
