#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  scanf("%d", &t);
  for (int tc = 1; tc <= t; ++tc) {
    int n;
    scanf("%d", &n);
    vector<pair<int, int>> pii(n, {0, 0});
    for (int i = 0; i < n; ++i) {
      scanf("%d", &pii[i].first), scanf("%d", &pii[i].second);
    }
    int time = 1;
    for (int j = 0; j < n; ++j) {
      if (time > pii[j].second) {
        printf("0");
      } else {
        printf("%d", max(pii[j].first, time));
        time = max(pii[j].first, time) + 1;
      }
      if (j == n - 1) {
        printf("\n");
      } else
        printf(" ");
    }
  }
  return 0;
}
