#include <bits/stdc++.h>
using namespace std;
int const Max = 1e6 + 10;
int mod = 1e9 + 7, INF = 1e9 + 10;
int last[Max];
bool mark[Max];
int dp[Max], l[Max], r[Max];
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++) cin >> l[i] >> r[i];
    for (int i = 1; i <= n; i++) {
      int cnt = 0;
      for (int j = i - 1; j >= 1; j--) {
        if (dp[j] >= l[i]) cnt++;
      }
      if (cnt > r[i] - l[i]) {
        dp[i] = 0;
        continue;
      }
      dp[i] = cnt + l[i];
    }
    for (int j = 1; j <= n; j++) cout << dp[j] << " ";
    cout << "\n";
  }
}
