#include <bits/stdc++.h>
using namespace std;
int t;
int n;
int l, r;
int main(void) {
  scanf("%d", &t);
  while (t--) {
    scanf("%d", &n);
    int d = 1;
    while (n--) {
      scanf("%d %d", &l, &r);
      if (d <= r)
        printf("%d ", max(l, d)), d = max(l, d) + 1;
      else
        printf("0 ");
    }
    putc('\n', stdout);
  }
  return 0;
}
