#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n, l, r, count = 0;
    cin >> n;
    while (n--) {
      cin >> l >> r;
      if (count < r) {
        if (count < l)
          count = l;
        else
          count++;
        cout << count << " ";
      } else {
        cout << 0 << " ";
      }
    }
    cout << endl;
  }
}
