#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:10240000")
using namespace std;
const int MAXN = 1010;
struct tnode {
  int l, r, num;
} a[MAXN];
int ans[MAXN];
bool cmp(tnode a, tnode b) {
  if (a.l == b.l) {
    return a.num < b.num;
  } else {
    return a.l < b.l;
  }
}
int main() {
  int T;
  scanf("%d", &T);
  while (T--) {
    int n;
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) {
      scanf("%d%d", &a[i].l, &a[i].r);
      a[i].num = i;
    }
    sort(a + 1, a + n + 1, cmp);
    memset(ans, 0, sizeof(ans));
    int now = a[1].l;
    for (int i = 1; i <= n; i++) {
      if (now < a[i].l) {
        now = a[i].l;
      }
      if (now <= a[i].r) {
        ans[a[i].num] = now;
        now++;
      }
    }
    for (int i = 1; i <= n; i++) {
      printf("%d ", ans[i]);
    }
    printf("\n");
  }
  return 0;
}
