#include <bits/stdc++.h>
using namespace std;
void solve() {
  int n;
  cin >> n;
  vector<int> ans;
  int cur = 1;
  for (int i = 0; i < n; i++) {
    int l, r;
    cin >> l >> r;
    if (cur > r)
      ans.push_back(0);
    else
      ans.push_back(max(cur, l)), cur = max(l, cur) + 1;
  }
  for (auto i : ans) cout << i << ' ';
  cout << endl;
}
int main() {
  int t;
  cin >> t;
  for (int i = 0; i < t; i++) {
    solve();
  }
  return 0;
}
