#include <bits/stdc++.h>
using namespace std;
int s[1010][2];
int main() {
  ios::sync_with_stdio(0), cin.tie(0);
  int t, time = 0, n;
  cin >> t;
  for (int i = 0; i < t; i++) {
    cin >> n;
    cin >> s[0][0] >> s[0][1];
    cout << s[0][0] << " ";
    time = s[0][0];
    for (int j = 1; j < n; j++) {
      cin >> s[j][0] >> s[j][1];
      if (time >= s[j][1]) {
        cout << "0 ";
      } else {
        cout << max(time + 1, s[j][0]) << " ";
        time = max(s[j][0], time + 1);
      }
    }
    cout << '\n';
  }
}
