#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n;
  while (n--) {
    cin >> m;
    int t = 1, cometime, dur;
    for (int j = 0; j < m; j++) {
      cin >> cometime >> dur;
      while (t < cometime) {
        t++;
      }
      if (t <= dur) {
        cout << t << " ";
      } else {
        cout << "0 ";
        continue;
      }
      t++;
    }
    cout << endl;
  }
}
