#include <bits/stdc++.h>
using namespace std;
int max(int a[], int n) {
  int max = a[0];
  for (int i = 1; i < n; i++)
    if (max < a[i]) max = a[i];
  return max;
}
void XoaPhanTu(int a[], int &n, int pos) {
  if (n <= 0) {
    return;
  }
  if (pos < 0) {
    pos = 0;
  } else if (pos >= n) {
    pos = n - 1;
  }
  for (int i = pos; i < n - 1; i++) {
    a[i] = a[i + 1];
  }
  --n;
}
int main() {
  int N, N1, i, j;
  cin >> N;
  int X[N];
  int X1[N];
  int Y[N];
  for (i = 0; i < N; i++) {
    cin >> X[i];
    cin >> X1[i];
  }
  for (i = 0; i < N; i++) {
    N1 = N;
    XoaPhanTu(X1, N1, i);
    Y[i] = max(X1, N - 1);
    for (i = 0; i < N; i++) {
      X1[i] = X[i];
    }
  }
  for (j = 0; j < N; j++) {
    cout << Y[j] << endl;
  }
}
