#include <bits/stdc++.h>
using namespace std;
template <class T>
class Rbt_Node {
 public:
  Rbt_Node() : key(T()), parent(NULL), left(NULL), right(NULL), color(false) {}
  Rbt_Node(T aim) : key(aim), left_node(0), right_node(0), color(true) {}
  T key;
  Rbt_Node *parent;
  Rbt_Node *left;
  Rbt_Node *right;
  int left_node;
  int right_node;
  bool color;
};
template <class T>
class Set {
 public:
  Set() : root(NIL) {}
  void Init();
  void Left_Rotate(Rbt_Node<T> *x);
  void Right_Rotate(Rbt_Node<T> *y);
  void Insert(const T &aim);
  void Insert_Fix_up(Rbt_Node<T> *New_Node);
  void Delete(const T &aim);
  void Delete_Fix_up(Rbt_Node<T> *Old_Node);
  void Clear() { Traversal(root, true); }
  void Start_Traver() { Traversal(root); }
  int Size() { return root->left_node + root->right_node + 1; }
  T Search_Num(int Num);
  int Search_Value(T aim);
  Rbt_Node<T> *Begin() { return Get_Minmum(); }
  Rbt_Node<T> *End() { return NIL; }

 private:
  Rbt_Node<T> *root;
  static Rbt_Node<T> *NIL;
  Rbt_Node<T> *Temp_Value;
  int Temp_Num;
  Rbt_Node<T> *Search_Delete(T aim);
  Rbt_Node<T> *Get_Minmum(Rbt_Node<T> *Start_Node, bool Delete_Sign = false);
  void Traversal(Rbt_Node<T> *Start_Node, bool Clear_Sign = false);
};
template <class T>
Rbt_Node<T> *Set<T>::NIL = new Rbt_Node<T>;
template <class T>
void Set<T>::Init() {
  root = NIL;
  Temp_Value = NIL;
  Temp_Num = 0;
}
template <class T>
void Set<T>::Left_Rotate(Rbt_Node<T> *x) {
  Rbt_Node<T> *y = x->right;
  x->right = y->left;
  if (y->left != NIL) {
    y->left->parent = x;
    x->right_node = y->left->left_node + y->left->right_node + 1;
  } else
    x->right_node = 0;
  y->left = x;
  y->left_node = x->left_node + x->right_node + 1;
  y->parent = x->parent;
  if (x == root)
    root = y;
  else if (x == x->parent->left)
    x->parent->left = y;
  else
    x->parent->right = y;
  x->parent = y;
}
template <class T>
void Set<T>::Right_Rotate(Rbt_Node<T> *y) {
  Rbt_Node<T> *x = y->left;
  y->left = x->right;
  if (x->right != NIL) {
    x->right->parent = y;
    y->left_node = x->right->left_node + x->right->right_node + 1;
  } else
    y->left_node = 0;
  x->right = y;
  x->right_node = y->left_node + y->right_node + 1;
  x->parent = y->parent;
  if (y == root)
    root = x;
  else if (y == y->parent->left)
    y->parent->left = x;
  else
    y->parent->right = x;
  y->parent = x;
}
template <class T>
void Set<T>::Insert(const T &aim) {
  if (Search_Value(aim) != 0) return;
  Temp_Value = NIL;
  Temp_Num = 0;
  Rbt_Node<T> *x = root;
  Rbt_Node<T> *y = NIL;
  Rbt_Node<T> *New_Node = new Rbt_Node<T>(aim);
  New_Node->left = NIL;
  New_Node->right = NIL;
  while (x != NIL) {
    y = x;
    if (aim < x->key) {
      x->left_node++;
      x = x->left;
    } else {
      x->right_node++;
      x = x->right;
    }
  }
  New_Node->parent = y;
  if (y == NIL)
    root = New_Node;
  else if (aim < y->key)
    y->left = New_Node;
  else
    y->right = New_Node;
  Insert_Fix_up(New_Node);
}
template <class T>
void Set<T>::Insert_Fix_up(Rbt_Node<T> *New_Node) {
  Rbt_Node<T> *y;
  while (New_Node->parent->color == true) {
    if (New_Node->parent == New_Node->parent->parent->left) {
      y = New_Node->parent->parent->right;
      if (y->color == true) {
        New_Node->parent->color = false;
        y->color = false;
        New_Node->parent->parent->color = true;
        New_Node = New_Node->parent->parent;
      } else {
        if (New_Node == New_Node->parent->right) {
          New_Node = New_Node->parent;
          Left_Rotate(New_Node);
        }
        New_Node->parent->color = false;
        New_Node->parent->parent->color = true;
        Right_Rotate(New_Node->parent->parent);
      }
    } else {
      y = New_Node->parent->parent->left;
      if (y->color == true) {
        New_Node->parent->color = false;
        y->color = false;
        New_Node->parent->parent->color = true;
        New_Node = New_Node->parent->parent;
      } else {
        if (New_Node == New_Node->parent->left) {
          New_Node = New_Node->parent;
          Right_Rotate(New_Node);
        }
        New_Node->parent->color = false;
        New_Node->parent->parent->color = true;
        Left_Rotate(New_Node->parent->parent);
      }
    }
  }
  root->color = false;
}
template <class T>
Rbt_Node<T> *Set<T>::Search_Delete(T aim) {
  if (Search_Value(aim) == 0) return NIL;
  Rbt_Node<T> *x = root;
  while (x != NIL) {
    if (aim < x->key) {
      x->left_node--;
      x = x->left;
    } else if (x->key < aim) {
      x->right_node--;
      x = x->right;
    } else
      return x;
  }
}
template <class T>
Rbt_Node<T> *Set<T>::Get_Minmum(Rbt_Node<T> *Start_Node, bool Delete_Sign) {
  Rbt_Node<T> *Ans_Node = Start_Node;
  while (Ans_Node->left != NIL) {
    if (Delete_Sign) Ans_Node->left_node--;
    Ans_Node = Ans_Node->left;
  }
  return Ans_Node;
}
template <class T>
void Set<T>::Delete(const T &aim) {
  Rbt_Node<T> *Old_Node = Search_Delete(aim);
  if (Old_Node != NIL) {
    Temp_Value = NIL;
    Temp_Num = 0;
    Rbt_Node<T> *x, *y;
    if (Old_Node->left == NIL || Old_Node->right == NIL)
      y = Old_Node;
    else {
      y = Get_Minmum(Old_Node->right, true);
      Old_Node->right_node--;
    }
    if (y->left != NIL)
      x = y->left;
    else
      x = y->right;
    x->parent = y->parent;
    if (x->parent == NIL)
      root = x;
    else if (y == y->parent->left)
      y->parent->left = x;
    else
      y->parent->right = x;
    if (y != Old_Node) Old_Node->key = y->key;
    if (y->color == false) Delete_Fix_up(x);
    delete y;
  }
}
template <class T>
void Set<T>::Delete_Fix_up(Rbt_Node<T> *Old_Node) {
  while (Old_Node != root && Old_Node->color == false) {
    Rbt_Node<T> *x;
    if (Old_Node == Old_Node->parent->left) {
      x = Old_Node->parent->right;
      if (x->color == true) {
        x->color = false;
        Old_Node->parent->color = true;
        Left_Rotate(Old_Node->parent);
        x = Old_Node->parent->right;
      }
      if (x->left->color == false && x->right->color == false) {
        x->color = true;
        Old_Node = Old_Node->parent;
      } else {
        if (x->right->color == false) {
          x->left->color = false;
          x->color = true;
          Right_Rotate(x);
          x = Old_Node->parent->right;
        }
        x->color = Old_Node->parent->color;
        Old_Node->parent->color = false;
        x->right->color = false;
        Left_Rotate(Old_Node->parent);
        Old_Node = root;
      }
    } else {
      x = Old_Node->parent->left;
      if (x->color == true) {
        x->color = false;
        Old_Node->parent->color = true;
        Right_Rotate(Old_Node->parent);
        x = Old_Node->parent->left;
      }
      if (x->right->color == false && x->left->color == false) {
        x->color = true;
        Old_Node = Old_Node->parent;
      } else {
        if (x->left->color == false) {
          x->right->color = false;
          x->color = true;
          Left_Rotate(x);
          x = Old_Node->parent->left;
        }
        x->color = Old_Node->parent->color;
        Old_Node->parent->color = false;
        x->left->color = false;
        Right_Rotate(Old_Node->parent);
        Old_Node = root;
      }
    }
  }
  Old_Node->color = false;
}
template <class T>
void Set<T>::Traversal(Rbt_Node<T> *Start_Node, bool Clear_Sign) {
  if (Start_Node == NIL) return;
  if (Start_Node->left != NIL) Traversal(Start_Node->left);
  if (!Clear_Sign) {
    cout << endl;
    if (Start_Node->parent != NIL) cout << Start_Node->parent->key.l << endl;
    cout << Start_Node->key.l << endl;
    cout << endl;
  }
  if (Start_Node->right != NIL) Traversal(Start_Node->right);
  if (Clear_Sign) {
    if (Start_Node != root)
      delete Start_Node;
    else
      root = NIL;
  }
}
template <class T>
T Set<T>::Search_Num(int Num) {
  if (Num > Size()) return End()->key;
  if (Num == Temp_Num + 1 && Temp_Num) {
    Temp_Num++;
    if (Temp_Value->right != NIL) {
      Temp_Value = Temp_Value->right;
      while (Temp_Value->left != NIL) Temp_Value = Temp_Value->left;
    } else if (Temp_Value == Temp_Value->parent->left)
      Temp_Value = Temp_Value->parent;
    else {
      while (Temp_Value == Temp_Value->parent->right)
        Temp_Value = Temp_Value->parent;
      Temp_Value = Temp_Value->parent;
    }
    return Temp_Value->key;
  }
  Rbt_Node<T> *Start_Node = root;
  while (Start_Node->left_node != Num - 1) {
    if (Start_Node->left_node < Num - 1) {
      Num -= (Start_Node->left_node + 1);
      Start_Node = Start_Node->right;
    } else
      Start_Node = Start_Node->left;
  }
  Temp_Num = Num;
  Temp_Value = Start_Node;
  return Start_Node->key;
}
template <class T>
int Set<T>::Search_Value(T aim) {
  Rbt_Node<T> *Start_Node = root;
  int Num = 0;
  while (Start_Node != NIL &&
         (Start_Node->key < aim || aim < Start_Node->key)) {
    if (Start_Node->key < aim) {
      Num += Start_Node->left_node + 1;
      Start_Node = Start_Node->right;
    } else
      Start_Node = Start_Node->left;
  }
  if (Start_Node == NIL) return 0;
  return Num + 1 + Start_Node->left_node;
}
class Seg1 {
 public:
  Seg1() {}
  Seg1(int l, int r, int num) : l(l), r(r), num(num) {}
  int l, r, num;
  bool operator<(const Seg1 &b) const { return l < b.l; }
};
class Seg2 {
 public:
  Seg2() {}
  Seg2(int l, int r, int num) : l(l), r(r), num(num) {}
  int l, r, num;
  bool operator<(const Seg2 &b) const { return r > b.r; }
};
Set<Seg1> s1;
Set<Seg2> s2;
int ans[200010];
int main() {
  s1.Init();
  s2.Init();
  int n, l, r;
  cin >> n;
  for (int i = 0; i < n; i++) {
    scanf("%d%d", &l, &r);
    s1.Insert(Seg1(l, r, i));
    s2.Insert(Seg2(l, r, i));
  }
  for (int i = 1; i <= n; i++) {
    Seg1 temp = s1.Search_Num(i);
    ans[temp.num] = s2.Size() - s2.Search_Value(Seg2(temp.l, temp.r, temp.num));
    s2.Delete(Seg2(temp.l, temp.r, temp.num));
  }
  for (int i = 0; i < n; i++) printf("%d\n", ans[i]);
  return 0;
}
