#include <bits/stdc++.h>
using namespace std;
template <typename S, typename T>
ostream& operator<<(ostream& out, pair<S, T> const& p) {
  out << '(' << p.first << ", " << p.second << ')';
  return out;
}
template <typename T>
ostream& operator<<(ostream& out, vector<T> const& v) {
  int l = v.size();
  for (int i = 0; i < l - 1; i++) out << v[i] << ' ';
  if (l > 0) out << v[l - 1];
  return out;
}
template <typename T>
void trace(const char* name, T&& arg1) {
  cout << name << " : " << arg1 << endl;
}
template <typename T, typename... Args>
void trace(const char* names, T&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ',');
  cout.write(names, comma - names) << " : " << arg1 << " | ";
  trace(comma + 1, args...);
}
const long double PI = 3.1415926535897932384626433832795;
const int N = 1005;
void solve() {
  vector<pair<int, pair<int, int> > > q;
  int n, l, r, ti = 0, ans[N];
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> l >> r;
    q.push_back({l, {i, r}});
  }
  sort(q.begin(), q.end());
  for (int i = 0; i < q.size(); i++) {
    int l = q[i].first, r = q[i].second.second, ind = q[i].second.first;
    if (ti > r) {
      ans[ind] = 0;
    } else if (ti <= l) {
      ti = l + 1;
      ans[ind] = l;
    } else {
      ans[ind] = ti;
      ti++;
    }
  }
  for (int i = 1; i <= n; i++) cout << ans[i] << ' ';
  cout << '\n';
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int t;
  cin >> t;
  while (t--) {
    solve();
  }
  return 0;
}
