#include <bits/stdc++.h>
using i8 = char;
using u8 = unsigned char;
using i16 = short int;
using u16 = unsigned short int;
using i32 = long int;
using u32 = unsigned long int;
using i64 = long long int;
using u64 = unsigned long long int;
using f32 = float;
using f64 = double;
using f80 = long double;
using namespace std;
void solve() {
  i64 n;
  cin >> n;
  i64 l[1010];
  i64 r[1010];
  for (i64 i = 0; i < n; ++i) cin >> l[i] >> r[i];
  i64 s = l[0];
  for (i64 i = 0; i < n; ++i) {
    if (s > r[i]) {
      cout << 0 << " ";
    } else if (l[i] > s) {
      s = l[i];
      cout << s++ << " ";
    } else {
      cout << s++ << " ";
    }
  }
  cout << endl;
}
int main(void) {
  i64 t;
  cin >> t;
  for (; t > 0; --t) {
    solve();
  }
  return 0;
}
