#include <bits/stdc++.h>
using namespace std;
int main() {
  int t, n, k;
  cin >> t;
  for (int T = 0; T < t; T++) {
    int n;
    cin >> n;
    vector<pair<int, int> > v(n);
    for (int i = 0; i < n; i++) {
      cin >> v[i].first >> v[i].second;
    }
    vector<int> a;
    int c = 1;
    for (int i = 0; i < n; i++) {
      c = max(c, v[i].first);
      if (v[i].first <= c && v[i].second >= c) {
        a.push_back(c);
        c++;
      } else {
        a.push_back(0);
      }
    }
    for (int i = 0; i < a.size(); i++) {
      cout << a[i] << " ";
    }
    cout << endl;
  }
  return 0;
}
