#include <bits/stdc++.h>
using namespace std;
long long i, n, a[1000001], l, r, t, s, j, ans[100001];
vector<pair<long long, pair<long long, long long> > > v;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> t;
  for (i = 1; i <= t; i++) {
    cin >> n;
    v.clear();
    for (j = 1; j <= n; j++) {
      cin >> l >> r;
      v.push_back({l, {j, r}});
    }
    sort(v.begin(), v.end());
    s = 0;
    for (j = 0; j < v.size(); j++) {
      s++;
      if (s > v[j].second.second) {
        s--;
        ans[v[j].second.first] = 0;
      } else {
        if (s < v[j].first) s = v[j].first;
        ans[v[j].second.first] = s;
      }
    }
    for (j = 1; j <= n; j++) cout << ans[j] << " ";
    cout << '\n';
  }
}
