#include <bits/stdc++.h>
using namespace std;
struct node {
  int l, r;
  int id;
} Node[1000 + 7];
bool cmp(node a, node b) {
  if (a.l != b.r)
    return a.l < b.l;
  else
    return a.id < b.id;
}
int main() {
  int t;
  cin >> t;
  while (t--) {
    memset(Node, 0, sizeof(Node));
    int n, timestep = 1;
    cin >> n;
    for (int i = 0; i < n; i++) {
      cin >> Node[i].l >> Node[i].r;
      Node[i].id = i;
    }
    for (int i = 0; i < n; i++) {
      if (timestep < Node[i].l) {
        timestep = Node[i].l;
      }
      if (timestep <= Node[i].r) {
        cout << timestep << ' ';
        timestep++;
      } else {
        cout << 0 << ' ';
      }
    }
    cout << endl;
  }
  return 0;
}
