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