#include <bits/stdc++.h>
using namespace std;
const int N = 10010;
int ans[N], vis[N], l[N], r[N];
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    memset(vis, 0, sizeof vis);
    for (int i = 0; i < n; i++) cin >> l[i] >> r[i];
    for (int i = 1; i <= 5010; i++) {
      bool flag = false;
      for (int j = 0; j < n; j++)
        if (!vis[j]) {
          flag = true;
          break;
        }
      if (!flag) break;
      for (int j = 0; j < n; j++) {
        if (vis[j]) continue;
        if (i > r[j]) {
          vis[j] = true;
          ans[j] = 0;
        }
        if (i >= l[j] && i <= r[j]) {
          ans[j] = i;
          vis[j] = true;
          break;
        }
      }
    }
    for (int i = 0; i < n; i++) cout << ans[i] << " ";
    cout << endl;
  }
}
