#include <bits/stdc++.h>
using namespace std;
long long mod = 1e9 + 7;
void boost() {
  std::ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
}
bool cmp(pair<pair<int, int>, int> a, pair<pair<int, int>, int> b) {
  if (a.first.first != b.first.first) return a.first.first < b.first.first;
  return a.second <= b.second;
}
int main() {
  boost();
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    vector<pair<pair<int, int>, int> > stud;
    int l, r;
    for (int i = 0; i < n; i++) {
      cin >> l >> r;
      stud.push_back(make_pair(make_pair(l, r), i + 1));
    }
    sort(stud.begin(), stud.end(), cmp);
    int sec = 1;
    for (int i = 0; i < stud.size(); i++) {
      if (sec <= stud[i].first.second) {
        if (sec >= stud[i].first.first)
          cout << sec << " ";
        else {
          sec = stud[i].first.first;
          cout << sec << "\n";
        }
        sec++;
      } else
        cout << 0 << " ";
    }
    cout << "\n";
  }
  return 0;
}
