#include <bits/stdc++.h>
using namespace std;
const int M = 2e5 + 7, inf = 1e9 + 7;
int main() {
  int tests;
  cin >> tests;
  for (int t = 1; t <= tests; t++) {
    int n;
    cin >> n;
    int cnt = 1;
    for (int i = 1; i <= n; i++) {
      int l, r;
      cin >> l >> r;
      if (cnt <= r)
        cout << max(l, cnt) << ' ', cnt = max(l + 1, cnt + 1);
      else
        cout << 0 << ' ';
    }
    cout << endl;
  }
}
