#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n, x, y;
    cin >> n;
    vector<pair<int, pair<int, int> > > v;
    for (int i = 0; i < n; i++) {
      cin >> x >> y;
      v.push_back({x, {i, y}});
    }
    int time = 1;
    sort(v.begin(), v.end());
    for (int i = 0; i < n; i++) {
      if (time <= v[i].second.second) {
        cout << max(v[i].first, time) << " ";
        time = max(time, v[i].first);
        time++;
      } else
        cout << "0 ";
    }
    cout << endl;
  }
}
