#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
int main() {
  cin.tie(0), cout.tie(0);
  ios::sync_with_stdio(false);
  int t;
  cin >> t;
  while (t--) {
    int n, l, r, now = 1;
    cin >> n;
    for (int i = 0; i < n; i++) {
      cin >> l >> r;
      if (now < l) {
        now = l;
      }
      if (now <= r) {
        cout << now << " ";
        now++;
      } else {
        cout << 0 << " ";
      }
    }
    cout << endl;
  }
}
