#include <bits/stdc++.h>
using namespace std;
struct point {
  int start, ender;
};
struct point2 {
  int start;
  int ender;
  int index;
};
bool cmp(point2 a, point2 b) {
  if (a.start == b.start) {
    return a.index < b.index;
  }
  return a.start < b.start;
}
int main() {
  int t;
  cin >> t;
  while (t > 0) {
    int n;
    cin >> n;
    point2 arr[n];
    for (int i = 0; i < n; i++) {
      int a, b;
      cin >> a >> b;
      point2 one;
      one.start = a;
      one.ender = b;
      one.index = i;
      arr[i] = one;
    }
    sort(arr, arr + n, cmp);
    int currentTime = arr[0].start + 1;
    cout << (currentTime - 1) << " ";
    for (int i = 1; i < n; i++) {
      if (arr[i].ender >= currentTime) {
        currentTime = max(currentTime, arr[i].start);
        cout << currentTime << " ";
        currentTime++;
      } else {
        cout << "0 ";
      }
    }
    cout << endl;
    t--;
  }
}
