#include <bits/stdc++.h>   using namespace std;   const long double pi = acos(-1);   const long long inf = 1LL << 30;   const double eps = 1e-9;   const long long mod = 1e9 + 7;   const int N = 100100;   pair<int, pair<int, int>> a[N];   int seg[N << 2], lazy[N << 2];   ;   int ans[N];   int dp[N];   void push(int nd, int L, int R) {     if (lazy[nd] == 0) return;     seg[nd] = 0;     if (L != R) {       lazy[nd << 1] = 1;       lazy[nd << 1 | 1] = 1;     }     lazy[nd] = 0;   }   void update(int nd, int L, int R, int idx, int val) {     if (L == R) {       seg[nd] = val;       return;     }     int mid = (L + R) >> 1;     if (idx <= mid)       update(nd << 1, L, mid, idx, val);     else       update(nd << 1 | 1, mid + 1, R, idx, val);     seg[nd] = seg[nd << 1] + seg[nd << 1 | 1];   }   long long query(int nd, int L, int R, int from, int to) {     push(nd, L, R);     if (from <= L && R <= to) return seg[nd];     if (from > R || to < L) return 0;     int mid = (L + R) >> 1;     long long leftAns = query(nd << 1, L, mid, from, to);     long long rightAns = query(nd << 1 | 1, mid + 1, R, from, to);     return leftAns + rightAns;   }   void updateRange(int nd, int L, int R, int from, int to) {     push(nd, L, R);     if (R < from || L > to) return;     if (from <= L && R <= to) {       lazy[nd] = 1;       push(nd, L, R);       return;     }     int mid = (L + R) >> 1;     updateRange(nd << 1, L, mid, from, to);     updateRange(nd << 1 | 1, mid + 1, R, from, to);     seg[nd] = seg[nd << 1] + seg[nd << 1 | 1];   }   int main() {     int n;     scanf( %d , &n);     for (int i = 0; i < n; i++) {       scanf( %d%d , &a[i].first, &a[i].second.first);       a[i].second.second = i;     }     sort(a, a + n);     for (int i = n - 1; i >= 0; i--) {       int j = lower_bound(                   a, a + n,                   make_pair(a[i].first + a[i].second.first, make_pair(0, 0))) -               a - 1;       dp[i] = 1 + query(1, 1, n, i, j);       updateRange(1, 1, n, i + 1, j);       update(1, 1, n, i, dp[i]);       ans[a[i].second.second] = dp[i];     }     for (int i = 0; i < n; i++) printf( %d  , ans[i]);   }   