#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  for (int i = 0; i < t; i++) {
    int n;
    cin >> n;
    int time = 0;
    for (int j = 0; j < n; j++) {
      int li, ri;
      cin >> li >> ri;
      if (time <= ri) {
        if (time < li) time = li;
        cout << time << " ";
        time++;
      } else {
        cout << 0 << " ";
      }
    }
    cout << endl;
  }
}
