#include <bits/stdc++.h>
using namespace std;
const int MAXN = 200000 + 5;
int n, m;
int res[MAXN];
struct s {
  int x, y, z;
} a[MAXN];
int cmp(const void* a, const void* b) {
  s* A = (s*)a;
  s* B = (s*)b;
  if ((A->x) - (B->x) != 0) {
    return (A->x) - (B->x);
  }
  return (A->z) - (B->z);
}
int main() {
  cin.sync_with_stdio(false);
  cout.sync_with_stdio(false);
  int T;
  cin >> T;
  while (T--) {
    cin >> n;
    for (int i = 0; i < n; i++) {
      cin >> a[i].x;
      cin >> a[i].y;
      a[i].z = i + 1;
    }
    qsort(a, n, sizeof(s), cmp);
    int time = 0;
    int cur = 0;
    while (cur < n) {
      if (a[cur].x > time) {
        time++;
        continue;
      }
      if (a[cur].y < time) {
        res[a[cur].z - 1] = 0;
        cur++;
        continue;
      }
      res[a[cur].z - 1] = time;
      cur++;
      time++;
    }
    for (int i = 0; i < n; i++) {
      cout << res[i] << " ";
    }
    cout << endl;
  }
  return 0;
}
