#include <bits/stdc++.h>
using namespace std;
const int INF = INT_MAX;
struct time {
  int l, r;
} a[1007];
int main() {
  int t;
  scanf("%d", &t);
  while (t--) {
    int n;
    scanf("%d", &n);
    int ans[1007];
    memset(a, 0, sizeof(a));
    for (int i = 1; i <= n; ++i) {
      scanf("%d %d", &a[i].l, &a[i].r);
    }
    int now = a[1].l, i = 1;
    while (i <= n) {
      now = max(now, a[i].l);
      bool pok = (a[i].r < now);
      if (pok) {
        ans[i] = 0;
        i++;
        continue;
      } else {
        ans[i] = now, now++, i++;
        continue;
      }
    }
    for (int i = 1; i <= n; ++i) {
      printf("%d ", ans[i]);
    }
    printf("\n");
  }
  return 0;
}
