#include <bits/stdc++.h>
using namespace std;
struct student {
  long long l;
  long long r;
  long long index;
};
int32_t main() {
  long long t;
  cin >> t;
  while (t--) {
    long long n;
    cin >> n;
    long long timecount = 0;
    student arr[n];
    long long ans[n];
    for (long long i = 0; i < n; i++) {
      cin >> arr[i].l >> arr[i].r;
      arr[i].index = i;
    }
    vector<student> v(n);
    v.clear();
    long long start = 0;
    long long count = 0;
    while (count < n) {
      for (long long i = start; arr[i].l <= timecount; i++) {
        if (arr[i].l == timecount) {
          v.push_back(arr[i]);
          start = i;
        }
      }
      long long flag = 1;
      if (!v.empty()) {
        while (flag) {
          if (v.empty()) {
            flag = 0;
          } else {
            student going = v[0];
            if (going.r < timecount) {
              ans[going.index] = 0;
              v.erase(v.begin());
              count++;
            } else {
              ans[going.index] = timecount;
              v.erase(v.begin());
              count++;
              flag = 0;
            }
          }
        }
      }
      timecount++;
    }
    for (long long i = 0; i < n; i++) {
      cout << ans[i] << " ";
    }
    cout << endl;
  }
  return 0;
}
