#include <bits/stdc++.h>
using namespace std;
int t, n, l[1002], r[1002], nowtime, ed, cnt;
int main() {
  cin >> t;
  while (t--) {
    cin >> n;
    for (int i = 1; i <= n; i++) {
      scanf("%d%d", l + i, r + i);
    }
    nowtime = 1;
    for (int i = 1; i <= n; i++) {
      if (nowtime < l[i]) {
        nowtime = l[i];
      }
      if (l[i] <= nowtime && nowtime <= r[i]) {
        cout << nowtime << " ";
        nowtime++;
      } else
        cout << "0"
             << " ";
    }
    cout << endl;
  }
  return 0;
}
