#include <bits/stdc++.h>
using namespace std;
int alpha[26] = {0}, dig[105] = {0};
long long int gcd(long long int a, long long int b) {
  if (a == 0) return b;
  return gcd(b % a, a);
}
long long int lcm(long long int a, long long int b) {
  return ((a * b) / gcd(a, b));
}
bool isPrime(int n) {
  if (n <= 1) return false;
  if (n <= 3) return true;
  if (n % 2 == 0 || n % 3 == 0) return false;
  for (int i = 5; i * i <= n; i = i + 6)
    if (n % i == 0 || n % (i + 2) == 0) return false;
  return true;
}
void getArr(int a[], int n) {
  for (int i = 0; i < n; i++) cin >> a[i];
}
void putArr(int a[], int n) {
  for (int i = 0; i < n; i++) cout << a[i] << " ";
  cout << "\n";
}
void initAlpha(string s) {
  int n = s.size();
  for (int i = 0; i < n; i++) alpha[s[i] - 'a']++;
}
void initDigit(int a[], int n) {
  for (int i = 0; i < n; i++) dig[a[i]]++;
}
bool isPalindrome(string input) {
  if (input == string(input.rbegin(), input.rend())) return true;
  return false;
}
int numLen(int n) {
  int len = 0;
  while (n != 0) {
    n /= 10;
    len++;
  }
  return len;
}
string str;
bool checkForSorting(int arr[], int n) {
  for (int i = 0; i < n - 1; i++) {
    if (arr[i] > arr[i + 1]) {
      if (str[i] == '1')
        swap(arr[i], arr[i + 1]);
      else
        return false;
    }
  }
  return true;
}
void robot() {
  int n;
  cin >> n;
  int time = 0;
  for (int i = 0; i < n; i++) {
    int l, r;
    cin >> l >> r;
    if (i == 0) {
      time = l;
      cout << time << " ";
    } else if (time < r) {
      if (time >= l)
        time = time + 1;
      else
        time = l;
      cout << time << " ";
    } else
      cout << "0 ";
  }
  cout << endl;
}
int main() {
  int t;
  cin >> t;
  while (t--) robot();
}
