#include <bits/stdc++.h>
using namespace std;
long long n, m, k, t, a[10000], ans, x, y;
int main() {
  cin >> t;
  while (1) {
    if (t == 0) break;
    t--;
    cin >> n;
    k = 0;
    for (int i = 0; i < n; i++) {
      cin >> x >> y;
      if (y >= k) {
        a[i] = max(x, k);
        k = a[i] + 1;
      } else {
        a[i] = 0;
      }
      cout << a[i] << ' ';
    }
    cout << endl;
  }
  return 0;
}
