#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  while (n--) {
    int m;
    cin >> m;
    int k = 1;
    for (int i = 0; i < m; i++) {
      int a, b;
      cin >> a >> b;
      while (k < a) k++;
      if (k <= b) {
        printf("%d ", k);
        k++;
      } else
        cout << "0"
             << " ";
    }
    cout << endl;
  }
}
