#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int t, n, x, y, s;
  queue<int> que;
  cin >> t;
  while (t--) {
    cin >> n;
    for (int i = 0; i < n; i++) {
      cin >> x >> y;
      que.push(x);
      que.push(y);
    }
    s = 0;
    while (!que.empty()) {
      x = que.front();
      que.pop();
      y = que.front();
      que.pop();
      if (s > y)
        cout << 0 << " ";
      else {
        s = max(s, x);
        cout << s << " ";
        s++;
      }
    }
    cout << "\n";
  }
  return 0;
}
