#include <bits/stdc++.h>
using namespace std;
struct stu {
  int et;
  int ot;
} st[1050];
int main() {
  int n;
  cin >> n;
  while (n--) {
    int x, time = 1;
    cin >> x;
    for (int i = 0; i < x; ++i) cin >> st[i].et >> st[i].ot;
    for (int i = 0; i < x; ++i) {
      if (time <= st[i].ot) {
        time = max(time, st[i].et);
        cout << time << " ";
        time += 1;
      } else {
        cout << "0"
             << " ";
      }
    }
    cout << endl;
  }
}
