#include <bits/stdc++.h>
using namespace std;
static const int MAXN = 1e3 + 10;
struct OP {
  int l, r, id;
};
OP a[MAXN];
int r[MAXN], t, n;
bool cmp(OP a, OP b) { return a.l == b.l ? a.id < b.id : a.l < b.l; }
int main() {
  scanf("%d", &t);
  while (t--) {
    scanf("%d", &n);
    int c = 1;
    for (int i = 1, x, y; i <= n; ++i)
      scanf("%d%d", &x, &y), a[i - 1] = {x, y, i};
    sort(a, a + n, cmp);
    for (int i = 0; i < n; ++i) {
      c < a[i].l                  ? r[a[i].id] = a[i].l,
                   c = a[i].l + 1 : c <= a[i].r ? r[a[i].id] = c,
                   ++c                          : r[a[i].id] = 0;
    }
    printf("%d", r[1]);
    for (int i = 2; i <= n; ++i) printf(" %d", r[i]);
    puts("");
  }
}
