#include <bits/stdc++.h>
using namespace std;
const int Maxn = 1000;
int n;
vector<int> ans;
int main() {
  int T;
  scanf("%d", &T);
  while (T--) {
    int t = 1;
    scanf("%d", &n);
    queue<pair<int, int> > q;
    for (int i = 1; i <= n; i++) {
      int l, r;
      scanf("%d %d", &l, &r);
      if (l > t) t = l;
      if (t <= r)
        ans.push_back(t), t++;
      else
        ans.push_back(0);
    }
    for (int i = 0; i < ans.size(); i++) {
      if (i != 0) printf(" ");
      printf("%d", ans[i]);
    }
    puts("");
    ans.clear();
  }
  return 0;
}
