#include <bits/stdc++.h>
using namespace std;
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << " : " << arg1 << " | ";
  __f(comma + 1, args...);
}
const int N = 1e4 + 10;
vector<int> L[N], R[N];
int ans[N];
int main() {
  int t;
  scanf("%d", &t);
  while (t--) {
    int n;
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) {
      int l, r;
      scanf("%d", &l);
      scanf("%d", &r);
      L[l].push_back(i);
      R[r].push_back(i);
      ans[i] = 0;
    }
    set<int> second;
    for (int ct = 1; ct < N; ct++) {
      for (auto y : L[ct]) {
        second.insert(y);
      }
      int guy = -1;
      if (!second.empty()) {
        guy = *second.begin();
        second.erase(second.begin());
      }
      for (auto y : R[ct]) {
        second.erase(y);
      }
      if (guy == -1) continue;
      ans[guy] = ct;
    }
    for (int i = 1; i <= n; i++) printf("%d ", ans[i]);
    puts("");
    for (int i = (0); i < (N); ++i) {
      L[i].clear();
      R[i].clear();
    }
  }
  return 0;
}
