#include <bits/stdc++.h>
using namespace std;
vector<int> ans;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    int arr, must;
    ans.clear();
    int tim = 1;
    for (int i = 1; i <= n; i++) {
      cin >> arr >> must;
      if (tim > must) {
        ans.push_back(0);
        continue;
      }
      if (tim >= arr) {
        ans.push_back(tim);
        tim++;
      } else {
        ans.push_back(arr);
        tim = arr + 1;
      }
    }
    for (int i = 0; i < ans.size(); i++) {
      if (i) cout << " ";
      cout << ans[i];
    }
    cout << endl;
  }
  return 0;
}
