#include <bits/stdc++.h>
using namespace std;
long long mod = 1e9 + 7;
bool ispalin(string str) {
  long long l = 0;
  long long h = str.size() - 1;
  while (h > l) {
    if (str[l++] != str[h--]) return 0;
  }
  return 1;
}
void isprime() {
  long long n = 10000;
  bool prime[n + 1];
  memset(prime, true, sizeof(prime));
  for (long long p = 2; p * p <= n; p++) {
    if (prime[p] == true)
      for (long long i = p * p; i <= n; i += p) prime[i] = false;
  }
}
long long numberOfDigits(long long n) {
  if (n == 1) return 1;
  long double d = (n * log10(1.6180339887498948)) - ((log10(5)) / 2);
  return ceil(d);
}
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(0);
  long long test = 1;
  cin >> test;
  while (test--) {
    long long n;
    cin >> n;
    long long c = 1;
    for (long long i = 0; i < n; i++) {
      long long x, y;
      cin >> x >> y;
      if (c == 1)
        cout << x << " ";
      else {
        if (y < c) {
          cout << "0 ";
          continue;
        }
        c = max(x, c);
        cout << c << " ";
      }
      c = max(x, c);
      c++;
    }
    cout << endl;
  }
  return 0;
}
