#include <bits/stdc++.h>
using namespace std;
const int inf = 1000000007;
pair<pair<int, int>, int> a[1007];
int ans[1007], a1[1007];
int main() {
  int t;
  cin >> t;
  while (t != 0) {
    t--;
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
      cin >> a[i].first.first >> a[i].second;
      a[i].first.second = i;
    }
    sort(a, a + n);
    int t = 1;
    for (int i = 0; i < n; i++) {
      a1[a[i].first.second] = i;
      if (a[i].second < t) {
        ans[i] = 0;
      } else {
        ans[i] = max(t, a[i].first.first);
        t = ans[i] + 1;
      }
    }
    cout << ans[a1[0]];
    for (int i = 1; i < n; i++) {
      cout << ' ' << ans[a1[i]];
    }
    cout << endl;
  }
  return 0;
}
