#include <bits/stdc++.h>
using namespace std;
void debug(int n) { printf("%d\n"); }
bool cmp(pair<int, pair<int, int> > &a, pair<int, pair<int, int> > &b) {
  if (a.second.first == b.second.first) {
    return a.first < b.first;
  }
  return a.second.first < b.second.first;
}
int main() {
  int n, u, v, kase;
  scanf("%d", &kase);
  while (kase--) {
    scanf("%d", &n);
    vector<pair<int, pair<int, int> > > q;
    for (int i = 0; i < n; i++) {
      scanf("%d%d", &u, &v);
      q.push_back(make_pair(i, make_pair(u, v)));
    }
    sort(q.begin(), q.end(), cmp);
    vector<int> idx;
    int time = 0;
    for (int i = 0; i < n; i++) {
      time = max(time, q[i].second.first);
      if (time > q[i].second.second) {
        idx.push_back(0);
      } else {
        idx.push_back(time);
        time++;
      }
    }
    for (auto i : idx) printf("%d ", i);
    printf("\n");
  }
}
