#include <bits/stdc++.h>
using namespace std;
int main() {
  long long t;
  cin >> t;
  while (t--) {
    long long n;
    cin >> n;
    long long l[1005], r[1005];
    long long i;
    for (i = 0; i < n; i++) {
      cin >> l[i] >> r[i];
    }
    long long time;
    long long queue = 0;
    for (i = 0; i < n; i++) {
      time = l[i];
      if (i != 0) {
        if (l[i] != l[i - 1]) queue -= l[i] - l[i - 1];
      }
      if (queue < 0) queue = 0;
      time += queue;
      queue++;
      if (time > r[i]) queue--;
      if (time <= r[i]) {
        cout << time << " ";
      } else
        cout << "0 ";
    }
    cout << endl;
  }
  return 0;
}
