#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 3;
const int M = 1e6 + 7;
const long long MOD = 1e9 + 7;
const long long INF = 1e18 + 9;
const int SM = 1e3 + 8;
const int logN = 20, BL = 400;
const double EPS = 3e-16;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0), cout.tie(0);
  long long q;
  cin >> q;
  while (q--) {
    long long n;
    cin >> n;
    vector<pair<long long, long long>> p(n);
    for (auto &i : p) cin >> i.first >> i.second;
    long long cur = p[0].first;
    for (long long i = 0; i < n; i++) {
      if (p[i].first <= cur && cur <= p[i].second) {
        cout << cur << " ";
        cur++;
      } else if (cur < p[i].first) {
        cur = p[i].first;
        cout << cur << " ";
        cur++;
      } else {
        cout << "0 ";
      }
    }
    cout << "\n";
  }
  return 0;
}
