#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.precision(10), cout << fixed;
  int t;
  cin >> t;
  while (t--) {
    int n, ans = 0;
    cin >> n;
    vector<pair<int, int>> v(n);
    for (int i = 0; i < n; ++i) cin >> v[i].first >> v[i].second;
    ans = v[0].first;
    cout << ans << " ";
    ans;
    for (int i = 1; i < n; ++i) {
      if (v[i].second <= ans) {
        cout << "0 ";
        continue;
      }
      ans = max(ans + 1, v[i].first);
      cout << ans << " ";
    }
    cout << '\n';
  }
  return 0;
}
