#include <bits/stdc++.h>
using namespace std;
vector<int> v;
int main() {
  int t;
  cin >> t;
  while (t--) {
    v.clear();
    int n;
    cin >> n;
    int a, b;
    int i, ti = 0;
    for (i = 1; i <= n; i++) {
      cin >> a >> b;
      if (i == 1 || ti < a) {
        ti = a;
      }
      if (b >= ti) {
        v.push_back(ti);
        ti++;
      } else
        v.push_back(0);
    }
    for (i = 0; i < n; i++) cout << v[i] << " ";
    printf("\n");
  }
  return 0;
}
