#include <bits/stdc++.h>
using namespace std;
struct node {
  int a, b, c;
  bool operator<(const node& x) const {
    if (a == x.a) return c < x.c;
    return a < x.a;
  }
} a[1007];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n, t;
  cin >> t;
  while (t--) {
    cin >> n;
    int time = 0, ans[1007];
    for (int i = 0; i < n; i++) {
      cin >> a[i].a >> a[i].b;
      a[i].c = i;
    }
    for (int i = 0; i < n; i++) {
      if (time >= a[i].b) {
        ans[a[i].c] = 0;
        continue;
      } else if (++time < a[i].a)
        time = a[i].a;
      ans[a[i].c] = time;
    }
    for (int i = 0; i < n; i++) cout << ans[i] << ' ';
    cout << endl;
  }
  return 0;
}
