#include <bits/stdc++.h>
using namespace std;
int t, n, c, l, r;
int main() {
  for (cin >> t; t--;) {
    cin >> n;
    c = 1;
    for (int i = 1; i <= n; i++) {
      cin >> l >> r;
      if (l >= c) c = l;
      if (r < c && i != 1) {
        cout << "0 ";
        continue;
      } else {
        cout << c << " ";
        c++;
      }
    }
    cout << '\n';
  }
}
