#include <bits/stdc++.h>
using namespace std;
const int LEN = 1009;
int t;
int n;
pair<int, int> person[LEN];
int main() {
  cin >> t;
  for (int w = 0; w < t; w++) {
    cin >> n;
    for (int i = 0; i < n; i++) {
      cin >> person[i].first >> person[i].second;
    }
    queue<int> q;
    vector<int> ans(n, 0);
    int p = 0;
    int now = 1;
    for (;; now++) {
      if (q.empty() && p >= n) break;
      while (p < n && now == person[p].first) {
        q.push(p);
        p++;
      }
      while (!q.empty() && person[q.front()].second < now) {
        q.pop();
      }
      if (!q.empty()) {
        ans[q.front()] = now;
        q.pop();
      }
    }
    for (int i = 0; i < n; i++) cout << ans[i] << " ";
    cout << "\n";
  }
  return 0;
}
