#include <bits/stdc++.h>
using namespace std;
const double PI = acos(-1.0);
const double EPS = (1e-10);
int main() {
  int tc;
  cin >> tc;
  while (tc--) {
    int n;
    cin >> n;
    vector<pair<int, int> > stud(n);
    for (int i = 0; i < n; i++) {
      int a, b;
      cin >> a >> b;
      stud[i] = make_pair(a, b);
    }
    int ans[n];
    ans[0] = stud[0].first;
    int cs = ans[0] + 1;
    for (int i = 1; i < n; i++) {
      if (cs < stud[i].first) {
        ans[i] = stud[i].first;
        cs = ans[i] + 1;
      } else {
        if (cs <= stud[i].second) {
          ans[i] = cs;
          cs++;
        } else {
          ans[i] = 0;
        }
      }
    }
    for (int i = 0; i < n; i++) cout << ans[i] << " ";
    cout << endl;
  }
}
