#include <bits/stdc++.h>
using namespace std;
const int mn = 3e5 + 5;
const long long int mod = 1e9 + 7;
const long long int inf = 1e18;
long long int inv(long long int a, long long int g) {
  long long int ag = 1;
  while (g) {
    if (g % 2 == 1) {
      ag = (ag % mod * a % mod) % mod;
    }
    a = (a % mod * a % mod) % mod;
    g >>= 1;
  }
  return ag % mod;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    int time = 1, l, r;
    while (n--) {
      cin >> l >> r;
      if (r < time) {
        cout << "0 ";
      } else if (l > time) {
        cout << l << " ";
        time = l + 1;
      } else {
        cout << time << " ";
        time += 1;
      }
    }
    cout << "\n";
  }
  return 0;
}
