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