#include <bits/stdc++.h>
using namespace std;
typedef struct __st {
  int at, lt;
  int ind;
} st;
bool cmp(st a, st b) {
  if (a.at == b.at)
    return a.ind < b.ind;
  else
    return a.at < b.at;
}
void solve(int t) {
  int n;
  cin >> n;
  vector<st> v(n);
  for (int i = 0; i < n; i++) {
    int x, y;
    cin >> x >> y;
    v[i].ind = i;
    v[i].at = x;
    v[i].lt = y;
  }
  sort(v.begin(), v.end(), cmp);
  int tm = 1;
  int ans[n];
  for (int i = 0; i < n; i++) {
    while (v[i].at > tm) tm++;
    if (v[i].lt < tm)
      ans[v[i].ind] = 0;
    else {
      ans[v[i].ind] = tm;
      ++tm;
    }
  }
  for (int i : ans) cout << i << " ";
  cout << "\n";
}
int main(void) {
  int i, T = 1;
  cin >> T;
  for (int i = 1; i <= T; i++) solve(i);
  return 0;
}
