#include <bits/stdc++.h>
using namespace std;
const int N = 5e3 + 7;
bool vis[N];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    priority_queue<int, std::vector<int>, std::greater<int> > pq[n + 1];
    for (int i = 1; i <= n; i++) {
      int l, r;
      cin >> l >> r;
      for (int j = l; j <= r; j++) {
        pq[i].push(j);
      }
    }
    int ans[n + 1];
    memset(vis, 0, sizeof(vis));
    memset(ans, 0, sizeof(ans));
    for (int i = 1; i <= n; i++) {
      while (!pq[i].empty()) {
        int x = pq[i].top();
        pq[i].pop();
        if (!vis[x]) {
          vis[x] = true;
          ans[i] = x;
          break;
        }
      }
    }
    for (int i = 1; i <= n; i++) cout << ans[i] << " ";
    cout << endl;
  }
  return 0;
}
