#include <bits/stdc++.h>
using namespace std;
vector<int> arrival;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    arrival.resize(n + 1, 0);
    int time = 1;
    for (int i = 1; i <= n; i++) {
      int l, r;
      cin >> l >> r;
      if (i == 1) time = l;
      if (r >= time) {
        arrival[i] = max(time, l);
        time = arrival[i] + 1;
      } else
        arrival[i] = 0;
    }
    for (int i = 1; i <= n; i++) cout << arrival[i] << " ";
    cout << endl;
  }
  return 0;
}
