#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  for (auto i = 0; i < t; i++) {
    int n;
    cin >> n;
    vector<pair<int, int> > p;
    vector<int> time(n);
    int k = 1;
    int max = 0;
    for (auto j = 0; j < n; j++) {
      int a, b;
      cin >> a >> b;
      p.push_back(make_pair(a, b));
      if (max < p[j].first) max = p[j].first;
      if (p[j].first == 1 && b >= k) {
        time[j] = k;
        k++;
      } else {
        time[j] = 0;
      }
    }
    for (auto f = 2; f <= max; f++) {
      if (k < f) {
        k = f;
      }
      for (auto j = 0; j < n; j++) {
        if (p[j].first == f && p[j].second >= k) {
          time[j] = k;
          k++;
        } else if (time[j] == 0) {
          time[j] = 0;
        }
      }
    }
    for (auto j = 0; j < n; j++) {
      cout << time[j] << " ";
    }
    cout << "\n";
  }
}
