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