#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
bool vis[maxn];
int l[maxn];
int r[maxn];
int res[maxn];
int main() {
  int T;
  cin >> T;
  while (T--) {
    memset(vis, 0, sizeof vis);
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) cin >> l[i] >> r[i];
    for (int i = 1; i <= 5100; i++) {
      bool flg = false;
      for (int j = 0; j < n; j++) {
        if (!vis[j]) {
          flg = true;
          break;
        }
      }
      if (!flg) break;
      for (int j = 0; j < n; j++) {
        if (vis[j]) continue;
        if (i > r[j]) {
          vis[j] = true;
          res[j] = 0;
        }
        if (l[j] <= i && r[j] >= i) {
          vis[j] = true;
          res[j] = i;
          break;
        }
      }
    }
    for (int i = 0; i < n; i++) {
      printf("%d ", res[i]);
    }
    cout << endl;
  }
  return 0;
}
