#include <bits/stdc++.h>
using namespace std;
int t;
int main() {
  cin >> t;
  while (t--) {
    int n, t1, t2, ans = 1, start = 0;
    cin >> n;
    for (int i = 1; i <= n; i++) {
      cin >> t1 >> t2;
      ans = max(ans, t1);
      if (t2 >= ans) {
        cout << ans << " ";
        ans++;
      } else {
        cout << 0 << " ";
      }
    }
    cout << endl;
  }
  return 0;
}
