#include <bits/stdc++.h>
using namespace std;
long long int convertstringtoint(string a) {
  long long int ans = 0;
  for (long long int i = 0; i < a.size(); i++) {
    ans = (ans * 10) + a[i] - '0';
    ans = ans;
  }
  return ans;
}
void solve() {
  long long int n;
  cin >> n;
  pair<long long int, long long int> a[n];
  queue<pair<long long int, long long int>> q;
  for (long long int i = 0; i < n; ++i) {
    cin >> a[i].first >> a[i].second;
    q.push({a[i].first, a[i].second});
  }
  vector<long long int> ans(n, 0);
  long long int t = 1;
  long long int index = 0;
  while (!q.empty()) {
    auto it = q.front();
    q.pop();
    long long int start = it.first;
    long long int final = it.second;
    if (t > final) {
      ans[index] = 0;
    } else {
      if (t < start) {
        t = start;
      }
      ans[index] = t;
      t++;
    }
    index++;
  }
  for (long long int i = 0; i < n; ++i) cout << ans[i] << " ";
  cout << '\n';
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long int t;
  cin >> t;
  while (t--) solve();
}
