#include <bits/stdc++.h>
using namespace std;
long long pow(long long a, long long b, long long MOD) {
  long long x = 1, y = a;
  while (b > 0) {
    if (b % 2 == 1) {
      x = (x * y);
      if (x > MOD) x %= MOD;
    }
    y = (y * y);
    if (y > MOD) y %= MOD;
    b /= 2;
  }
  return x;
}
pair<int, int> a[1004];
int main() {
  ios_base::sync_with_stdio(0);
  int t, n, i, j, k, l;
  cin >> t;
  while (t--) {
    cin >> n;
    int sum = 0;
    for (i = 1; i <= n; i++) {
      cin >> a[i].first >> a[i].second;
      sum = max(a[i].first, sum);
      if (sum > a[i].second) {
        cout << "0 ";
        continue;
      }
      cout << sum << " ";
      sum++;
    }
    cout << "\n";
  }
  return 0;
}
