#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N=4e5+10;
const int inf=1e9+10;
struct WAR{
int l,r;
}a[N];
int ne[N][30];
bool cmp(WAR a,WAR b){
return a.l<b.l;
}
int ans[N];
signed main(){
int n,m;
cin>>n>>m;
for(int i=1;i<=n;i++){
cin>>a[i].l>>a[i].r;
if(a[i].l>a[i].r) a[i].r+=m;
a[i+n].l=a[i].l+m;
a[i+n].r=a[i].r+m;
}
sort(a+1,a+n+1,cmp);
memset(ne,0x3f3f3f3f,sizeof(ne));
int l=1;
for(int i=1;l<=2*n&&i<=2*n;i++){
if(a[i].l>a[l].r){
ne[l][0]=i-1;//找下一个 (贪心)
l++;
i--;
}
}
for(int i=l;i<=2*n;i++){
ne[i][0]=2*n;
}
for(int j=1;j<=25;j++){
for(int i=1;i<=2*n;i++){
ne[i][j]=ne[ne[i][j-1]][j-1];//倍增
}
}
for(int i=1;i<=n;i++){
int h=i;
for(int j=25;j>=0;j--){
if(a[ne[h][j]].r-a[i].l<m){
if(ne[h][j]!=h){
h=ne[h][j];
ans[i]+=(1<<j);//记录答案
}
}
}
ans[i]+=2;
}
for(int i=1;i<=n;i++){
cout<<ans[i]<<" ";
}
return 0;
}