#include <bits/stdc++.h>
using namespace std;
const long long sz = 2e5 + 5;
int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};
long long fExpo(long long x, long long y) {
  long long res = 1ll;
  x = x % 998244353;
  while (y > 0) {
    if (y & 1) res = (res * x) % 998244353;
    y = y >> 1;
    x = (x * x) % 998244353;
  }
  return res;
}
int mx = -1, mn = 30;
vector<long long> a[30];
vector<long long> vis(30);
void solve() {
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    vector<int> l(n), r(n);
    for (int i = 0; i < n; i++) cin >> l[i] >> r[i];
    int last = 0;
    for (int i = 0; i < n; i++) {
      if (last > r[i]) {
        cout << 0 << ' ';
        continue;
      }
      last = max(l[i], last);
      cout << last << ' ';
      last++;
    }
    cout << endl;
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  solve();
  return 0;
}
