#include <bits/stdc++.h>
using namespace std;
const int maxn = 1005;
int a[maxn];
int main() {
  int t, l, r, n;
  scanf("%d", &t);
  while (t--) {
    scanf("%d", &n);
    int time = 1;
    memset(a, 0, sizeof(a));
    for (int i = 0; i < n; i++) {
      scanf("%d%d", &l, &r);
      if (time < l) time = l;
      if (time <= r) {
        a[i] = time;
        time++;
      }
    }
    for (int i = 0; i < n; i++) {
      printf("%d ", a[i]);
    }
    printf("\n");
  }
  return 0;
}
