#include <bits/stdc++.h>
using namespace std;
int main() {
  int T;
  scanf("%d", &T);
  while (T--) {
    int n;
    scanf("%d", &n);
    int ans[1005];
    int time = 1, k = 0;
    for (int i = 1; i <= n; i++) {
      int s, t;
      scanf("%d%d", &s, &t);
      if (t >= time) {
        if (s > time) {
          time = s;
        }
        ans[k++] = time;
        time++;
      } else
        ans[k++] = 0;
    }
    for (int i = 0; i < n; i++) {
      if (i) printf(" ");
      printf("%d", ans[i]);
    }
    printf("\n");
  }
  return 0;
}
