#include <bits/stdc++.h>
using namespace std;
const int Nmax = 1005;
int Q, inc[Nmax], sf[Nmax], n;
int main() {
  cin >> Q;
  while (Q--) {
    cin >> n;
    for (int i = 1; i <= n; i++) cin >> inc[i] >> sf[i];
    int mx = -1;
    for (int i = 1; i <= n; i++) {
      mx = max(mx, inc[i]);
      if (mx > sf[i])
        cout << "0 ";
      else {
        cout << mx << " ";
        mx++;
      }
    }
    cout << "\n";
  }
  return 0;
}
