#include <bits/stdc++.h>
using namespace std;
int a[1001], b[1001], ans[1001];
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++) {
      cin >> a[i] >> b[i];
      ans[i] = 0;
    }
    int ind = 1;
    for (int i = 1; i <= n; i++) {
      if (ind <= b[i]) {
        if (ind >= a[i])
          ans[i] = ind++;
        else {
          ans[i] = a[i];
          ind = a[i] + 1;
        }
      }
    }
    for (int i = 1; i <= n; i++) cout << ans[i] << " ";
    cout << endl;
  }
}
