#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    int l[n], r[n];
    pair<int, pair<int, int> > p[n];
    for (int i = 0; i < n; i++) {
      cin >> l[i] >> r[i];
      p[i] = make_pair(l[i], make_pair(i, r[i]));
    }
    sort(p, p + n);
    int arr[n];
    int br = 0;
    for (int i = 0; i < n; i++) {
      int idx = p[i].second.first;
      int ll = p[i].first;
      int rr = p[i].second.second;
      br = max(ll, br);
      if (br > rr) {
        arr[idx] = 0;
      } else {
        arr[idx] = br;
        br++;
      }
    }
    for (int i = 0; i < n; i++) {
      cout << arr[i] << " ";
    }
    cout << endl;
  }
  return 0;
}
