#include <bits/stdc++.h>
int main() {
  int t;
  scanf("%d", &t);
  while (t--) {
    int n;
    scanf("%d", &n);
    int a[20005], b[20005];
    for (int i = 0; i < n; i++) scanf("%d %d", &a[i], &b[i]);
    int num = 1;
    for (int i = 0; i < n; i++) {
      if (num < a[i]) {
        num = a[i];
      }
      if (num <= b[i]) {
        printf("%d ", num);
        num++;
      } else
        printf("0 ");
    }
    printf("\n");
  }
  return 0;
}
