#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_DEPRECATE

#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

using namespace std;

#pragma comment(linker, "/STACK:64000000")

template<class T> inline T sqr (T x) {return x * x;}

typedef long long int64;
typedef unsigned long long uint64;
typedef pair<int, int> pii;
typedef pair<int, pii> pip;
typedef pair<pii, int> ppi;
typedef pair<int64, int64> pii64;
typedef pair<double, double> pdd;
typedef pair<string, int> psi;
typedef pair<int, string> pis;
#define FAIL ++*(int*)0
#define eps  1e-8
#define inf  0x7f7f7f7f
#define MP make_pair
#define sz(C) (int)((C).size())
#define all(C) (C).begin(), (C).end()
#define TASK "test"
#define RR 151

int n;
ppi a[1 << 7];
int ans[1 << 7];
char used[1 << 24];

int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    scanf("%d", &n);
    for (int i = 0; i < n; ++i) {
        scanf("%d%d", &a[i].first.first, &a[i].first.second);
        a[i].second = i;
    }
    sort(a, a + n);
    int last = 0;
    for (int i = 0; i < n; ++i) {
        int l = a[i].first.first;
        int r = a[i].first.second;
        int id = a[i].second;
        if (!used[l]) {
            used[l] = true;
            last = ans[id] = l;
            continue;
        }
        last = l;
        for (; used[last]; ++last) ;
        ans[id] = last;
        used[last] = true;
        if (last > r) FAIL;
    }
    for (int i = 0; i < n; ++i)
        printf("%d ", ans[i]);

    return 0;
}


#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_DEPRECATE

#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

using namespace std;

#pragma comment(linker, "/STACK:64000000")

template<class T> inline T sqr (T x) {return x * x;}

typedef long long int64;
typedef unsigned long long uint64;
typedef pair<int, int> pii;
typedef pair<int, pii> pip;
typedef pair<pii, int> ppi;
typedef pair<int64, int64> pii64;
typedef pair<double, double> pdd;
typedef pair<string, int> psi;
typedef pair<int, string> pis;
#define FAIL ++*(int*)0
#define eps  1e-8
#define inf  0x7f7f7f7f
#define MP make_pair
#define sz(C) (int)((C).size())
#define all(C) (C).begin(), (C).end()
#define TASK "test"
#define RR 151

int n;
ppi a[1 << 7];
int ans[1 << 7];
char used[1 << 24];

int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    scanf("%d", &n);
    for (int i = 0; i < n; ++i) {
        scanf("%d%d", &a[i].first.first, &a[i].first.second);
        a[i].second = i;
    }
    for (int i = 0; i < n; ++i) {
        sort(a + i, a + n);
        int l = a[i].first.first;
        int r = a[i].first.second;
        int id = a[i].second;
        ans[id] = l;
        if (l > r) FAIL;
        for (int j = i + 1; j < n; ++j) {
            a[j].first.first = max(a[j].first.first, l + 1);
        }
    }
    for (int i = 0; i < n; ++i)
        printf("%d ", ans[i]);

    return 0;
}


#include <iostream>
#include <stdio.h>
#include <string>

using namespace std;

struct det
{
	int l, r;
	bool us;
};

int n;
det f[102];

int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	scanf("%d", &n);
	int ml = -1000000;
	for (int i = 0; i < n; i++)
	{
		scanf("%d %d", &f[i].l, &f[i].r);
		ml = min(f[i].l, ml);
	}
	int g;
	for (int kk = 0; kk < n; kk++)
	{
		g = 0;
		while (f[g].us)
			g++;
		for (int i = 0; i < n; i++)
		{
			if (!f[i].us)
			{
				if (f[i].l <= ml)
				{
					if (f[g].l > ml)
						g = i;
					else
					{
						if (f[i].r < f[g].r)
							g = i;
					}
				}
				else
				{
					if (f[g].l > ml)
					{
						if (f[i].l < f[g].l || (f[i].l == f[g].l && f[i].r < f[g].r))
							g = i;
					}
				}
			}
		}
		f[g].us = true;
			if (kk == n - 1)
				printf("%d\n", g + 1);
			else
				printf("%d ", g + 1);
			ml = max(ml, f[g].l) + 1;
	}
	return 0;
}


#include <iostream>
#include <stdio.h>
#include <string>

using namespace std;

struct det
{
	int l, r;
	bool us;
};

int n;
det f[102];
int res[102];

int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	scanf("%d", &n);
	int ml = -1000000;
	for (int i = 0; i < n; i++)
	{
		scanf("%d %d", &f[i].l, &f[i].r);
		ml = min(f[i].l, ml);
	}
	int g;
	for (int kk = 0; kk < n; kk++)
	{
		g = 0;
		while (f[g].us)
			g++;
		for (int i = 0; i < n; i++)
		{
			if (!f[i].us)
			{
				if (f[i].l <= ml)
				{
					if (f[g].l > ml)
						g = i;
					else
					{
						if (f[i].r < f[g].r)
							g = i;
					}
				}
				else
				{
					if (f[g].l > ml)
					{
						if (f[i].l < f[g].l || (f[i].l == f[g].l && f[i].r < f[g].r))
							g = i;
					}
				}
			}
		}
		f[g].us = true;
			/*if (kk == n - 1)
				printf("%d\n", g + 1);
			else
				printf("%d ", g + 1);*/
			ml = max(ml, f[g].l) + 1;
			res[g + 1] = ml - 1;
	}
	for (int i = 1; i <= n; i++)
	{
		if (i == n)
			printf("%d\n", res[i]);
		else
			printf("%d ", res[i]);
	}
	return 0;
}


#include <iostream>
#include <stdio.h>
#include <string>

using namespace std;

struct det
{
	int l, r;
	bool us;
};

int n;
det f[102];

int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	scanf("%d", &n);
	int ml = -1000000;
	for (int i = 0; i < n; i++)
	{
		scanf("%d %d", &f[i].l, &f[i].r);
		ml = min(f[i].l, ml);
	}
	int g;
	for (int kk = 0; kk < n; kk++)
	{
		g = 0;
		while (f[g].us)
			g++;
		for (int i = 0; i < n; i++)
		{
			if (f[i].us == false)
			{
				if (f[i].l <= ml && f[g].l <= ml)
				{
					if (f[i].r < f[g].r)
						g = i;
				}
				if (f[i].l > ml && f[g].l > ml)
				{
					if (f[i].l < f[g].l)
						g = i;
				}
				if (f[i].l <= ml && f[g].l > ml)
					g = i;
				/*if ((f[i].l > ml && f[i].l < f[g].l) || ((f[i].l <= ml && f[g].l <= ml) && f[g].r > f[i].r))
				{
					g = i;
				}*/

			}
		}
		f[g].us = true;
			if (kk == n - 1)
				printf("%d\n", g + 1);
			else
				printf("%d ", g + 1);
			ml = max(ml, f[g].l) + 1;
	}
	return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;

struct block {
	int l, r, k, d;
	bool operator<(const block &nw) const {
		//return (l <nw.l || (l == nw.l && r < nw.r));
		return (d < nw.d);
	}
	static block make(int l, int r, int k, int d) {
		block nw;
		nw.l = l;
		nw.r = r;
		nw.k = k;
		nw.d = d;
		return nw;
	}
};

const int MN = 100 + 10;

block arr[MN];
int ans[MN];
bool used[1000 * 1000 * 10 + 10];

int main() {
        /*freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);*/
        int n;
		cin >> n;
		for(int i = 0; i < n; i ++) {
			int x, y;
			cin >> x >> y;
			arr[i] = block::make(x, y, i, y - x);
		}
		sort(arr, arr + n);
		int curr = 0;
		for(int i = 0; i < n; i ++) {
			int curr = arr[i].l;
			while (used[curr])
				curr ++;
			ans[arr[i].k] = curr;
			used[curr] = true;
		}
		for(int i = 0; i < n; i ++)
			cout << ans[i] << " ";
        return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;

struct block {
	int l, r, k;
	bool operator<(const block &nw) const {
		return (l <nw.l || (l == nw.l && r < nw.r));
	}
	static block make(int l, int r, int k) {
		block nw;
		nw.l = l;
		nw.r = r;
		nw.k = k;
		return nw;
	}
};

const int MN = 100 + 10;

block arr[MN];
int ans[MN];

int main() {
        /*freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);*/
        int n;
		cin >> n;
		for(int i = 0; i < n; i ++) {
			int x, y;
			cin >> x >> y;
			arr[i] = block::make(x, y, i);
		}
		int curr = 0;
		for(int i = 0; i < n; i ++) {
			if (curr < arr[i].l)
				curr = arr[i].l;
			ans[arr[i].k] = curr ++;
		}
		for(int i = 0; i < n; i ++)
			cout << ans[i] << " ";
        return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;

struct block {
	int l, r, k, d;
	bool operator<(const block &nw) const {
		return (d < nw.d || (d == nw.d && l < nw.l) || (d == nw.d && l == nw.l && r < nw.r));
	}
	static block make(int l, int r, int k, int d) {
		block nw;
		nw.l = l;
		nw.r = r;
		nw.k = k;
		nw.d = d;
		return nw;
	}
};

const int MN = 100 + 10;

block arr[MN];
int ans[MN];
bool used[1000 * 1000 * 10 + 10];
bool done[MN];

int main() {
        /*freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);*/
        int n;
		cin >> n;
		for(int i = 0; i < n; i ++) {
			int x, y;
			cin >> x >> y;
			arr[i] = block::make(x, y, i, y - x);
		}
		sort(arr, arr + n);
		int kol = 0;
		while (kol < n) {
			sort(arr, arr + n);
			for(int i = 0; i < n; i ++) {
				if (done[arr[i].k])
					continue;
				int curr = arr[i].l;
				while (used[curr])
					curr ++;
				ans[arr[i].k] = curr;
				used[curr] = true;
				done[arr[i].k] = true;
				kol ++;
				for(int j = 0; j < n; j ++)
					if (arr[j].l <= curr && arr[j].r >= curr)
						arr[j].d --;
				break;
			}
		}
		for(int i = 0; i < n; i ++)
			cout << ans[i] << " ";
        return 0;
}


#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <cctype>
using namespace std;
int n,m,was[200],l[200],r[200],num[200],dp[200],ans[200],st[200],sp;
void swap (int &a, int &b) {
	int tmp=a;
	a=b;
	b=tmp;
}
int main () {
#ifndef ONLINE_JUDGE
        freopen ("input.txt","r",stdin);
        freopen ("output.txt","w",stdout);
#endif
    cin>>n;
	for (int i=1; i<=n; i++) {
		cin>>l[i]>>r[i];
		num[i]=i;
	}
	for (int i=1; i<=n; i++)
		for (int j=i+1; j<=n; j++)
			if (l[j]<l[i]) {
				swap(l[i],l[j]);
				swap(r[i],r[j]);
				swap(num[i],num[j]);
			}
	int cur,otr=1;
	while (otr<=n) {
		cur=l[otr];
		st[++sp]=otr;
		otr++;
		while (sp) {
			while (otr<=n && l[otr]==cur) {
				st[++sp]=otr;
				otr++;
			}
			int best=1;
			for (int i=2; i<=sp; i++)
				if (r[st[i]]<r[st[best]]) best=i;
			ans[st[best]]=cur;
			cur++;
			for (int i=best; i<sp; i++)
				st[i]=st[i+1];
			sp--;
		}
	}
	for (int i=1; i<=n; i++)
		for (int j=1; j<=n; j++)
			if (num[j]==i)
				cout<<ans[j]<<" ";
}


#include<iostream>
#include<queue>
#include<vector>
#include<algorithm>
#define maxn 10000001
using namespace std;
int match[maxn];
bool walk[maxn];
int a[101],b[101];
int n,m;
bool Find_path(int k){
    for(int i=a[k]; i<=b[k]; i++){
        if(!walk[i]){
            walk[i]=1;
            if( match[i]==-1 || Find_path(match[i]) ){
                match[i]=k;
                return 1;
            }
        }
    }
    return 0;
}
int Hungary(){
    int  sum(0);
    memset(match,-1,sizeof(match));
    for(int i=1; i<=n; ++i){
        memset(walk,0,sizeof(walk));
        if(Find_path(i))++sum;
    }
    return sum;
}
int main(){
    //freopen("a.txt","r",stdin);
    int i,x,y,j;m=-1;
    scanf("%d",&n);
    for(i=1;i<=n;i++){
        scanf("%d%d",&x,&y);
        if(m<y)m=y;
        a[i]=x;b[i]=y;
    }
    Hungary();
    int ans[101];
    for(i=1;i<=m;i++)if(match[i]!=-1)ans[match[i]]=i;
    for(i=1;i<n;i++){
        printf("%d ",ans[i]);
    }printf("%d\n",ans[i]);
    return 0;
}


#include<iostream>
#include<queue>
#include<vector>
#include<algorithm>
#define maxn 10000001
using namespace std;
bool cmap[100][maxn];
int match[maxn];
bool walk[maxn];
int n,m;
bool Find_path(int k){
    for(int i=1; i<=m; i++){
        if(cmap[k][i]==0)continue;
        if(!walk[i]){
            walk[i]=1;
            if( match[i]==-1 || Find_path(match[i]) ){
                match[i]=k;
                return 1;
            }
        }
    }
    return 0;
}
int Hungary(){
    int  sum(0);
    memset(match,-1,sizeof(match));
    for(int i=1; i<=n; ++i){
        memset(walk,0,sizeof(walk));
        if(Find_path(i))++sum;
    }
    return sum;
}
int main(){
    //freopen("a.txt","r",stdin);
    int i,x,y,j;m=-1;
    scanf("%d",&n);
    for(i=1;i<=n;i++){
        scanf("%d%d",&x,&y);
        if(y>m)m=y;
        for(j=x;j<=y;j++)cmap[i][j]=1;
    }
    Hungary();
    int ans[100];
    for(i=1;i<=m;i++)if(match[i]!=-1)ans[match[i]]=i;
    for(i=1;i<n;i++){
        printf("%d ",ans[i]);
    }printf("%d\n",ans[i]);
    return 0;
}


#include<iostream>
#include<queue>
#include<vector>
#include<algorithm>
#define maxn 10000001
using namespace std;
int match[maxn];
bool walk[maxn];
int a[101],b[101];
int n,m;
bool Find_path(int k){
    for(int i=a[k]; i<=b[k]; i++){
        if(!walk[i]){
            walk[i]=1;
            if( match[i]==-1 || Find_path(match[i]) ){
                match[i]=k;
                return 1;
            }
        }
    }
    return 0;
}
int Hungary(){
    int  sum(0);
    memset(match,-1,sizeof(match));
    for(int i=1; i<=n; ++i){
        memset(walk,0,sizeof(walk));
        if(Find_path(i))++sum;
    }
    return sum;
}
int main(){
    //freopen("a.txt","r",stdin);
    int i,x,y,j;m=-1;
    scanf("%d",&n);
    for(i=1;i<=n;i++){
        scanf("%d%d",&x,&y);
        if(m<y)m=y;
        a[i]=x;b[i]=y;
    }
    Hungary();
    int ans[100];
    for(i=1;i<=m;i++)if(match[i]!=-1)ans[match[i]]=i;
    for(i=1;i<n;i++){
        printf("%d ",ans[i]);
    }printf("%d\n",ans[i]);
    return 0;
}


#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cmath>
#include <ctime>
#include <cassert>
#include <float.h>

using namespace std;

#define REP(i, from, to) for (int i = (from); i < (to); ++i)
#define FOR(i, n) REP(i, 0, (n))
#define ALL(x) x.begin(), x.end()
#define SIZE(x) (int)x.size()
#define PB push_back
#define MP make_pair

//typedef long long i64;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<VS> VVS;
typedef pair<int, int> PII;

struct item {
  item() {}
  item(int x, int y, int index) : x(x), y(y), index(index) {}
  int x, y, index;
};

bool operator<(item const& lhs, item const& rhs) {
  return MP(lhs.x, lhs.y) < MP(rhs.x, rhs.y);
}

int main() {
  //freopen("input.txt", "r", stdin);
  //freopen("output.txt", "w", stdout);

  int n;
  cin >> n;

  vector<item> a(n);
  FOR (i, n) {
    int x, y;
    cin >> x >> y;
    a[i] = item(x, y, i);
  }

  VI res(n);
  int last = -1;

  while (!a.empty()) {
    sort(ALL(a));

    res[a[0].index] = a[0].x;
    vector<item> b;
    REP (i, 1, SIZE(a)) {
      if (a[i].x == a[0].x)
        ++a[i].x;
      if (a[i].x <= a[i].y)
        b.PB(a[i]);
    }

    a = b;
  }

  FOR (i, SIZE(res)) {
    if (i) cout << " ";
    cout << res[i];
  }

  cout << "\n";

  return 0;
}


#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cmath>
#include <ctime>
#include <cassert>
#include <float.h>

using namespace std;

#define REP(i, from, to) for (int i = (from); i < (to); ++i)
#define FOR(i, n) REP(i, 0, (n))
#define ALL(x) x.begin(), x.end()
#define SIZE(x) (int)x.size()
#define PB push_back
#define MP make_pair

//typedef long long i64;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<VS> VVS;
typedef pair<int, int> PII;

struct item {
  item() {}
  item(int x, int y, int index) : x(x), y(y), index(index) {}
  int x, y, index;
};

bool operator<(item const& lhs, item const& rhs) {
  if (lhs.y - lhs.x == rhs.y - rhs.x)
    return MP(lhs.x, lhs.y) < MP(rhs.x, rhs.y);
  return lhs.y - lhs.x < rhs.y - rhs.x;
}

int main() {
  //freopen("input.txt", "r", stdin);
  //freopen("output.txt", "w", stdout);

  int n;
  cin >> n;

  vector<item> a(n);
  FOR (i, n) {
    int x, y;
    cin >> x >> y;
    a[i] = item(x, y, i);
  }

  sort(ALL(a));
  VI res(n);
  int last = -1;

  vector<bool> used(1e7 + 1);

  FOR (i, n) {
    int k = -1;
    REP (j, a[i].x, a[i].y + 1) {
      if (!used[j]) {
        k = j;
        break;
      }
    }

    used[k] = 1;
    res[a[i].index] = k;
  }

  FOR (i, SIZE(res)) {
    if (i) cout << " ";
    cout << res[i];
  }

  cout << "\n";

  return 0;
}


#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cmath>
#include <ctime>
#include <cassert>
#include <float.h>

using namespace std;

#define REP(i, from, to) for (int i = (from); i < (to); ++i)
#define FOR(i, n) REP(i, 0, (n))
#define ALL(x) x.begin(), x.end()
#define SIZE(x) (int)x.size()
#define PB push_back
#define MP make_pair

//typedef long long i64;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<VS> VVS;
typedef pair<int, int> PII;

int main() {
  //freopen("input.txt", "r", stdin);
  //freopen("output.txt", "w", stdout);

  int n;
  cin >> n;

  vector<PII> a(n);
  FOR (i, n) cin >> a[i].first >> a[i].second;

  sort(ALL(a));
  VI res;
  int last = -1;

  FOR (i, n) {
    int k;
    REP (j, a[i].first, a[i].second + 1)
      if (last < j) {
        k = j;
        break;
      }

    res.PB(k);
    last = k;
  }

  FOR (i, SIZE(res)) {
    if (i) cout << " ";
    cout << res[i];
  }

  cout << "\n";

  return 0;
}


#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cmath>
#include <ctime>
#include <cassert>
#include <float.h>

using namespace std;

#define REP(i, from, to) for (int i = (from); i < (to); ++i)
#define FOR(i, n) REP(i, 0, (n))
#define ALL(x) x.begin(), x.end()
#define SIZE(x) (int)x.size()
#define PB push_back
#define MP make_pair

//typedef long long i64;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<VS> VVS;
typedef pair<int, int> PII;

int main() {
  //freopen("input.txt", "r", stdin);
  //freopen("output.txt", "w", stdout);

  int n;
  cin >> n;

  vector<pair<PII, int>> a(n);
  FOR (i, n) {
    int x, y;
    cin >> x >> y;
    a[i] = (MP(MP(x, y), i));
  }

  sort(ALL(a));
  VI res(n);
  int last = -1;

  FOR (i, n) {
    int k;
    if (last < a[i].first.first)
      k = a[i].first.first;
    else {
      k = last + 1;
    }

    res[a[i].second] = k;
    last = k;
  }

  FOR (i, SIZE(res)) {
    if (i) cout << " ";
    cout << res[i];
  }

  cout << "\n";

  return 0;
}


#include <iostream>
#include <cstdio>
#include <vector>
#include <set>
#include <deque>
#include <string>
#include <string.h>
#include <sstream>
#include <algorithm>
#include <map>
#include <cmath>
#include <malloc.h>
using namespace std;

#define MAXN (1<<24)
const int c = 10000001;
int all[2*MAXN], num[2*MAXN];

int mn (int cur, int l, int r, int h, int t) {
	if (h>r || t<l) return c;
	if (h<=l && t>=r) return num[cur];
	int m = (l+r)/2;
	return min(mn(2*cur, l, m, h, t), mn(2*cur+1, m+1, r, h, t)) + all[cur];
}

void add (int cur, int l, int r, int h, int t, int x) {
	if (h>r || t<l) return;
	if (h<=l && t>=r) {
		num[cur]+=x;
		all[cur]+=x;
		return;
	}
	int m = (l+r)/2;
	add(2*cur, l, m, h, t, x);
	add(2*cur+1, m+1, r, h, t, x);
	num[cur] = min(num[2*cur], num[2*cur+1]) + all[cur];
}

struct lr {
	int l, r;
	int ind;
};
lr mas[110];
int ans[110], n;
bool operator < (const lr &a, const lr &b) {
	if (a.r < b.r) return true;
	if (a.r > b.r) return false;
	return a.l < b.l;
}
int main()
{
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
#endif
	cin>>n;
	for (int i=0; i<n; i++) {
		cin>>mas[i].l>>mas[i].r;
		mas[i].ind = i;
	}
	int mx = (1<<23);
	all[1] = num[1] = 1;
	all[3] = num[3] = mx;
	mx/=2;
	int st = 2, prev, next;
	while(1) {
		prev = (1<<st);
		next = (1<<(st+1));
		for (int i=prev+1; i<next; i+=2)
			all[i] = num[i] = mx;
		st++;
		mx/=2;
		if (next == 2*MAXN) break;
	}
	//for (int i=1; i<=MAXN; i++)
	//	add(1, 1, MAXN, i, MAXN, 1);

	sort(mas, mas+n);
	for (int i=0; i<n; i++) {
		ans[mas[i].ind] = mn(1, 1, MAXN, mas[i].l, mas[i].r);
		add(1, 1, MAXN, ans[mas[i].ind], ans[mas[i].ind], c);
	}
	for (int i=0; i<n; i++) {
		cout<<ans[i];
		if (i != n-1) cout<<' ';
	}
    return 0;
}


#include <iostream>
#include <cstdio>
#include <vector>
#include <set>
#include <deque>
#include <string>
#include <string.h>
#include <sstream>
#include <algorithm>
#include <map>
#include <cmath>
#include <malloc.h>
using namespace std;

#define MAXN (1<<24)
const int c = 10000001;
int tree[2*MAXN];

void update (int v, int x) {
	v += MAXN-1;
	tree[v] = x;
	while (v>1) {
		tree[v>>1] = min(tree[v], tree[v^1]);
		v>>=1;
	}
}
int find_min (int l, int r) {
	l += MAXN-1;
	r += MAXN-1;
	int mn = c;
	while (l<=r) {
		if (l&1) mn = min(tree[l], mn);
		if (!(r&1)) mn = min(tree[r], mn);
		l = (l+1)/2;
		r = (r-1)/2;
	}
	return mn;
}

struct lr {
	int l, r;
	int ind;
};
lr mas[110];
int ans[110], n;
bool operator < (const lr &a, const lr &b) {
	if (a.r < b.r) return true;
	if (a.r > b.r) return false;
	return a.l < b.l;
}
int main()
{
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
#endif
	cin>>n;
	for (int i=0; i<n; i++) {
		cin>>mas[i].l>>mas[i].r;
		mas[i].ind = i;
	}
	sort(mas, mas+n);

	int level = 24;
	int kol = MAXN;
	int st = 0;
	while (level) {
		tree[1+(1<<level)-1] = 1;
		for (int i=2; i<=kol; i++) {
			int v = i+(1<<level)-1;
			tree[v] = tree[v-1] + (1<<st);
		}
		st++;
		kol/=2;
		level--;
	}
	tree[1] = 1;

	for (int i=0; i<n; i++) {
		ans[mas[i].ind] = find_min(mas[i].l, mas[i].r);
		update(ans[mas[i].ind], c);
	}
	for (int i=0; i<n; i++) {
		cout<<ans[i];
		if (i != n-1) cout<<' ';
	}
    return 0;
}


#include <iostream>
#include <cstdio>
#include <vector>
#include <set>
#include <deque>
#include <string>
#include <string.h>
#include <sstream>
#include <algorithm>
#include <map>
#include <cmath>
#include <malloc.h>
using namespace std;

struct lr {
	int l, r;
	int ind;
};
lr mas[110];
int ans[110], n;
bool operator < (const lr &a, const lr &b) {
	if (a.l < b.l) return true;
	if (a.l > b.l) return false;
	return a.r < b.r;
}
int main()
{
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
#endif
	cin>>n;
	for (int i=0; i<n; i++) {
		cin>>mas[i].l>>mas[i].r;
		mas[i].ind = i;
	}
	sort(mas, mas+n);
	ans[mas[0].ind] = mas[0].l;
	for (int i=1; i<n; i++)
		ans[mas[i].ind] = max(ans[mas[i-1].ind] + 1, mas[i].l);
	for (int i=0; i<n; i++) {
		cout<<ans[i];
		if (i != n-1) cout<<' ';
	}
    return 0;
}


#include <iostream>
#include <cstdio>
#include <vector>
#include <set>
#include <deque>
#include <string>
#include <string.h>
#include <sstream>
#include <algorithm>
#include <map>
#include <cmath>
#include <malloc.h>
using namespace std;

#define MAXN (1<<24)
const int c = 10000001;
int tree[2*MAXN];

void update (int v, int x) {
	v += MAXN-1;
	tree[v] = x;
	while (v>1) {
		tree[v>>1] = min(tree[v], tree[v^1]);
		v>>=1;
	}
}
int find_min (int l, int r) {
	l += MAXN-1;
	r += MAXN-1;
	int mn = c;
	while (l<=r) {
		if (l&1) mn = min(tree[l], mn);
		if (!(r&1)) mn = min(tree[r], mn);
		l = (l+1)/2;
		r = (r-1)/2;
	}
	return mn;
}

struct lr {
	int l, r;
	int ind;
};
lr mas[110];
int ans[110], n;
bool operator < (const lr &a, const lr &b) {
	if (a.r < b.r) return true;
	if (a.r > b.r) return false;
	return a.l < b.l;
}
int main()
{
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
#endif
	cin>>n;
	for (int i=0; i<n; i++) {
		cin>>mas[i].l>>mas[i].r;
		mas[i].ind = i;
	}
	sort(mas, mas+n);
	for(int i=1; i<=MAXN; i++)
		update(i, i);

	for (int i=0; i<n; i++) {
		ans[mas[i].ind] = find_min(mas[i].l, mas[i].r);
		update(ans[mas[i].ind], c);
	}
	for (int i=0; i<n; i++) {
		cout<<ans[i];
		if (i != n-1) cout<<' ';
	}
    return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <ctime>
#include <map>
#include <set>
#include <string>
#include <stack>
#include <queue>

using namespace std;

#define inf (1000*1000*1000)
#define eps 1e-9
#define PI 3.1415926535897932385
#define forn(i, m, n) for(int (i) = m; i < (n); i++)
#define sz(n) ((int)(n).size())
#define vint vector<int>
#define mk(a, b) (make_pair((a), (b)))

void print(string s){
	cout << s << endl;

	exit(0);
}

bool p[10000020];
int ans[110];

struct ot{
	int l, r, num;
};

bool cmp(ot a, ot b){
	return (a.l - a.r) < (b.l - b.r);
}

void solve(){
	int n;

	cin >> n;

	vector<ot > o(n);

	forn(i, 0, n){
		cin >> o[i].l >> o[i].r;
		o[i].num = i;
	}

	sort(o.begin(), o.end(), cmp);

	forn(i, 0, sz(o)){
		forn(j,o[i].l,o[i].r + 1)
			if (!p[j]){
				p[j] = true;

				ans[o[i].num] = j;

				break;
			}
	}

	forn(i, 0, n)
		cout << ans[i] << " ";
}

int main(){
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	solve();

	return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <ctime>
#include <map>
#include <set>
#include <string>
#include <stack>
#include <queue>

using namespace std;

#define inf (1000*1000*1000)
#define eps 1e-9
#define PI 3.1415926535897932385
#define forn(i, m, n) for(int (i) = m; i < (n); i++)
#define sz(n) ((int)(n).size())
#define vint vector<int>
#define mk(a, b) (make_pair((a), (b)))

void print(string s){
	cout << s << endl;

	exit(0);
}

bool p[10000020], e[110];
int ans[110];

struct ot{
	int l, r, num;
};

void solve(){
	int n;

	cin >> n;

	vector<ot > o(n);

	forn(i, 0, n){
		cin >> o[i].l >> o[i].r;
		o[i].num = i;
	}

	forn(l, 0, n){
		int m = -1;

		forn(i, 0, n)
			if (!e[i] && (m == -1 || (o[i].l < o[m].l || (o[i].l == o[m].l && o[i].r - o[i].l < o[m].r - o[m].l))))
				m = i;

		e[m] = true;
		ans[m] = o[m].l;

		forn(j, 0, n)
			if (!e[j] && o[m].l == o[j].l)
				o[j].l++;
	}

	forn(i, 0, n)
		cout << ans[i] << " ";
}

int main(){
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	solve();

	return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <ctime>
#include <map>
#include <set>
#include <string>
#include <stack>
#include <queue>

using namespace std;

#define inf (1000*1000*1000)
#define eps 1e-9
#define PI 3.1415926535897932385
#define forn(i, m, n) for(int (i) = m; i < (n); i++)
#define sz(n) ((int)(n).size())
#define vint vector<int>
#define mk(a, b) (make_pair((a), (b)))

void print(string s){
	cout << s << endl;

	exit(0);
}

bool p[10000020], e[110];
int ans[110];

struct ot{
	int l, r, num, x;
};

bool operator < (ot a, ot b){
	return (a.r - a.l) < (b.r - b.l);
}

void solve(){
	int n;

	cin >> n;

	vector<ot > o(n);

	forn(i, 0, n){
		cin >> o[i].l >> o[i].r;
		o[i].num = i;
		o[i].x = o[i].r - o[i].l + 1;
	}

	forn(l, 0, n){
		int m = -1;

		forn(i, 0, n)
			if (!e[i] && (m == -1 || o[i].x < o[m].x))
				m = i;

		e[m] = true;

		forn(i, o[m].l, o[m].r + 1)
			if (!p[i]){
				p[i] = true;

				ans[m] = i;

				forn(j, 0, n)
					if (i >= o[j].l && i <= o[j].r)
						o[j].x--;

				break;
			}
	}

	forn(i, 0, n)
		cout << ans[i] << " ";
}

int main(){
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	solve();

	return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <ctime>
#include <map>
#include <set>
#include <string>
#include <stack>
#include <queue>

using namespace std;

#define inf (1000*1000*1000)
#define eps 1e-9
#define PI 3.1415926535897932385
#define forn(i, m, n) for(int (i) = m; i < (n); i++)
#define sz(n) ((int)(n).size())
#define vint vector<int>
#define mk(a, b) (make_pair((a), (b)))

void print(string s){
	cout << s << endl;

	exit(0);
}

bool p[10000020];
int ans[110];

struct ot{
	int l, r, num;
};

bool cmp(ot a, ot b){
	return (a.r - a.l) < (b.r - b.l);
}

void solve(){
	int n;

	cin >> n;

	vector<ot > o(n);

	forn(i, 0, n){
		cin >> o[i].l >> o[i].r;
		o[i].num = i;
	}

	sort(o.begin(), o.end(), cmp);

	forn(i, 0, sz(o)){
		forn(j,o[i].l,o[i].r + 1)
			if (!p[j]){
				p[j] = true;

				ans[o[i].num] = j;

				break;
			}
	}

	forn(i, 0, n)
		cout << ans[i] << " ";
}

int main(){
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	solve();

	return 0;
}


#include<iostream>
const int maxn = 10000001;
using namespace std;
int match[maxn];
bool walk[maxn];
int a[101],b[101];
int n,m;
int dfs(int k){
    for(int i=a[k]; i<=b[k]; i++){
        if(!walk[i]){
            walk[i]=true;
            if( match[i]==-1 || dfs(match[i]) ){
                match[i]=k;
                return 1;
            }
        }
    }
    return 0;
}
int matcher(){
    int  sum=0;
    memset(match,-1,sizeof(match));
    for(int i=1; i<=n; ++i){
        memset(walk,0,sizeof(walk));
        if(dfs(i))
            ++sum;
    }
    return sum;
}
int main(){
    int i,x,y,j;m=-1;
     int ans[101];
    scanf("%d",&n);
    for(i=1;i<=n;i++){
        scanf("%d%d",&x,&y);
        if(m<y)m=y;
        a[i]=x;b[i]=y;
    }
    //cout << matcher() << endl;
    matcher();
    for(i=1;i<=m;i++)
        if(match[i]!=-1)
            ans[match[i]]=i;
        for(i=1;i<=n;i++)
        {
            cout << ans[i];
            if(i!=n)
                cout << " ";
            else
                cout << endl;
        }
        return 0;
}


#include<iostream>
using namespace std;

struct node{

	int begin;
	int end;
	int w;
}l[109];

int cmp(const void *a,const void *b){

	if(((node *)a)->begin!=((node *)b)->begin)
		return ((node *)a)->begin-((node *)b)->begin;
	if(((node *)a)->end!=((node *)b)->end)
		return ((node *)a)->end-((node *)b)->end;

}

int main(){
	int n;
	int str[290];
	cin >> n ;
	for(int i=0; i<n; ++i){
		cin >> l[i].begin >>l[i].end;
		l[i].w=i;
	}
	qsort(l,n,sizeof(l[0]),cmp);
// 	for(int i=0; i<n; ++i)
// 		cout<< l[i].begin<<" "<<l[i].end<<" "<<l[i].w<<endl;
	int begin=0;
	for(int i=0; i<n; ++i){
		if(l[i].begin>begin){
			begin=l[i].begin;
		}
		else{
			if((begin+1)<=l[i].end){
				begin+=1;
			}
		}
		str[l[i].w]=begin;
	}
	for(int i=0; i<n; ++i){
		cout<< str[i];
		if(i<n) cout<<" ";
	}
	cout<<endl;
	return 0;
}


#include<iostream>
using namespace std;

struct node{

	int begin;
	int end;
}l[109];

int cmp(const void *a,const void *b){
	if((*(node *)a).begin!=(*(node *)b).begin)
		return (*(node *)a).begin-(*(node *)b).begin;
	else
		return (*(node *)a).end-(*(node *)b).end;

}

int main(){
	int n;
	while(cin >> n ){
		for(int i=0; i<n; ++i)
			cin >> l[i].begin >>l[i].end;
		qsort(l,n,sizeof(l[0]),cmp);
		cout<<l[0].begin;
		int begin=l[0].begin;
		for(int i=1; i<n; ++i){
			if(i< n) cout<<" ";
			if(l[i].begin>begin){
				begin=l[i].begin;
				cout<<begin;
			}
			else{
				if((begin+1)<=l[i].end){
					begin+=1;
					cout<< begin;
				}
			}
		}
		cout<<endl;
	}
	return 0;
}


#include<iostream>
using namespace std;

struct node{

	int begin;
	int end;
	int w;
}l[109];

int cmp(const void *a,const void *b){

	if((*(node *)a).begin!=(*(node *)b).begin)
		return (*(node *)a).begin-(*(node *)b).begin;
	else
		return (*(node *)a).end-(*(node *)b).end;

}

int str[290];
int main(){
	int n;
	cin >> n ;
		for(int i=0; i<n; ++i){
			cin >> l[i].begin >>l[i].end;
			l[i].w=i;
		}
		qsort(l,n,sizeof(l[0]),cmp);
		int begin=0;
		for(int i=0; i<n; ++i){
			if(l[i].begin>begin){
				begin=l[i].begin;
			}
			else{
				if((begin+1)<=l[i].end){
					begin+=1;
				}
			}
			str[l[i].w]=begin;
		}
		for(int i=0; i<n; ++i){
			cout<< str[i];
			if(i<n) cout<<" ";
		}
		cout<<endl;
	return 0;
}


#include<iostream>
using namespace std;

struct node{

	int begin;
	int end;
	int w;
}l[109];

int cmp(const void *a,const void *b){

	if((*(node *)a).begin!=(*(node *)b).begin)
		return (*(node *)a).begin-(*(node *)b).begin;
	else
		return (*(node *)a).end-(*(node *)b).end;

}

int main(){
	int n;
	int str[290];
	cin >> n ;
	for(int i=0; i<n; ++i){
		cin >> l[i].begin >>l[i].end;
		l[i].w=i;
	}
	qsort(l,n,sizeof(l[0]),cmp);
	int begin=0;
	for(int i=0; i<n; ++i){
		if(l[i].begin>begin){
			begin=l[i].begin;
		}
		else{
				begin+=1;
		}
		str[l[i].w]=begin;
	}
	for(int i=0; i<n; ++i){
		cout<< str[i];
		if(i<n) cout<<" ";
	}
	cout<<endl;
	return 0;
}


#include<iostream>
using namespace std;

struct node{

	int begin;
	int end;
}l[109];

int cmp(const void *a,const void *b){
	if((*(node *)a).begin!=(*(node *)b).begin)
		return (*(node *)a).begin-(*(node *)b).begin;
	else
		return (*(node *)a).end-(*(node *)b).end;

}

int main(){
	int n;
	while(cin >> n ){
		for(int i=0; i<n; ++i)
			cin >> l[i].begin >>l[i].end;
			qsort(l,n,sizeof(l[0]),cmp);
		    int count=1;
			cout<<l[0].begin;
			int begin=l[0].begin;
			for(int i=1; i<n; ++i){
				if(count< n) cout<<" ";
				if(l[i].begin>begin){
					begin=l[i].begin;
					cout<<begin;
					count++;
				}
				else{
					if((begin+1)<=l[i].end){
					   begin+=1;
						cout<< begin;
					}
				}

				if(count==n) break;
			}
				cout<<endl;
		}
	return 0;
}


#include<iostream>
using namespace std;

struct node{

	int begin;
	int end;
}l[109];

int cmp(const void *a,const void *b){
	if((*(node *)a).end!=(*(node *)b).end)
		return (*(node *)a).begin-(*(node *)b).begin;
	else
		return (*(node *)a).end-(*(node *)b).end;

}

int main(){
	int n;
	while(cin >> n ){
		for(int i=0; i<n; ++i)
			cin >> l[i].begin >>l[i].end;
			qsort(l,n,sizeof(l[0]),cmp);
		    int count=1;
			cout<<l[0].begin;
			int begin=l[0].begin;
			for(int i=1; i<n; ++i){
				if(count< n) cout<<" ";
				if(l[i].begin>begin){
					begin=l[i].begin;
					cout<<begin;
					count++;
				}
				else{
					if((begin+1)<l[i].end){
					   begin+=1;
						cout<< begin;
					}
				}

				if(count==n) break;
			}
				cout<<endl;
		}
	return 0;
}


#include<iostream>
using namespace std;

struct node{

	int begin;
	int end;
	int w;
}l[109];

int cmp(const void *a,const void *b){
	if((*(node *)a).begin!=(*(node *)b).begin)
		return (*(node *)a).begin-(*(node *)b).begin;
	else
		return (*(node *)a).end-(*(node *)b).end;

}

int str[290];
int main(){
	int n;
	while(cin >> n ){
		for(int i=0; i<n; ++i){
			cin >> l[i].begin >>l[i].end;
			l[i].w=i;
		}
		qsort(l,n,sizeof(l[0]),cmp);
		int begin=-1;
		for(int i=0; i<n; ++i){
			if(l[i].begin>begin){
				begin=l[i].begin;
			}
			else{
				if((begin+1)<=l[i].end){
					begin+=1;
				}
			}
			str[l[i].w]=begin;
		}
		for(int i=0; i<n; ++i){
			cout<< str[i];
			if(i<n) cout<<" ";
		}
		cout<<endl;
	}
	return 0;
}


#include <iostream>
#include <algorithm>

using namespace std;
class Data
{
public:
	int a,b,numb,day,u;
	bool operator<(const Data& rhs) const
	{
		if(a==rhs.a)
		{
			if(b<rhs.b)
				return true;
			else
				return false;
		}
		if(a<rhs.a)
			return true;
		return false;
	};
};
Data arr[200];
int main()
{
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);

	int n,lastDay=-1;

	cin>>n;

	for(int i=0;i<n;i++)
	{
		arr[i].numb=i;
		cin>>arr[i].a>>arr[i].b;
	}

	sort(arr,arr+n);
	bool flag=true;
	lastDay=arr[0].a;
	while(flag)
	{
		flag=false;
		for(int i=0;i<n;i++)
		{
			if(arr[i].u)
				continue;
			lastDay=max(lastDay,arr[i].a);
			arr[i].day=lastDay;
			arr[i].u=1;
			lastDay++;
			for(int j=0;j<n;j++)
				if(arr[j].a<lastDay || arr[j].b>=lastDay)
					arr[j].a=lastDay;
			sort(arr,arr+n);
			flag=true;
		}
	}

	for(int i=0;i<n;i++)
		for(int j=0;j<n;j++)
			if(arr[j].numb==i)
				cout<<arr[j].day<<" ";

	return 0;
}


#include <iostream>
#include <algorithm>

using namespace std;
class Data
{
public:
	int a,b,numb,day,u;
	bool operator<(const Data& rhs) const
	{
		if(a==rhs.a)
		{
			if(b<rhs.b)
				return true;
			else
				return false;
		}
		if(a<rhs.a)
			return true;
		return false;
	};
};
Data arr[200];
int main()
{
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);

	int n,lastDay=-1;

	cin>>n;

	for(int i=0;i<n;i++)
	{
		arr[i].numb=i;
		cin>>arr[i].a>>arr[i].b;
	}

	sort(arr,arr+n);
	bool flag=true;
	lastDay=arr[0].a;
	while(flag)
	{
		flag=false;
		for(int i=0;i<n;i++)
		{
			if(arr[i].u)
				continue;
			lastDay=max(lastDay,arr[i].a);
			arr[i].day=lastDay;
			arr[i].u=1;
			lastDay++;
			for(int j=0;j<n;j++)
				if(arr[j].a<lastDay)
					arr[j].a=lastDay;
			sort(arr,arr+n);
			flag=true;
		}
	}

	for(int i=0;i<n;i++)
		for(int j=0;j<n;j++)
			if(arr[j].numb==i)
				cout<<arr[j].day<<" ";

	return 0;
}


#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);

	int n,lastDay=-1;

	cin>>n;
	pair<int,int> arr[200];
	for(int i=0;i<n;i++)
		cin>>arr[i].first>>arr[i].second;
	sort(arr,arr+n);

	for(int i=0;i<n;i++)
	{
		lastDay++;
		lastDay=max(lastDay,arr[i].first);
		if(i)
			cout<<" ";
		cout<<lastDay;
	}

	return 0;
}


#include <iostream>
#include <algorithm>

using namespace std;
class Data
{
public:
	int a,b,numb,day;
	bool operator<(const Data& rhs) const
	{
		if(a==rhs.a)
		{
			if(b<rhs.b)
				return true;
			else
				return false;
		}
		if(a<rhs.a)
			return true;
		return false;
	};
};
int main()
{
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);

	int n,lastDay=-1;

	cin>>n;
	Data arr[200];
	for(int i=0;i<n;i++)
	{
		arr[i].numb=i;
		cin>>arr[i].a>>arr[i].b;
	}

	sort(arr,arr+n);

	for(int i=0;i<n;i++)
	{
		lastDay++;
		lastDay=max(lastDay,arr[i].a);
		arr[i].day=lastDay;
	}

	for(int i=0;i<n;i++)
		for(int j=0;j<n;j++)
			if(arr[j].numb==i)
				cout<<arr[j].day<<" ";

	return 0;
}


#include <iostream>
#include <algorithm>

using namespace std;
class Data
{
public:
	int a,b,numb,day,u;
	bool operator<(const Data& rhs) const
	{
		if(a==rhs.a)
		{
			if(b<rhs.b)
				return true;
			else
				return false;
		}
		if(a<rhs.a)
			return true;
		return false;
	};
};
Data arr[200];
int main()
{
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);

	int n,lastDay=-1;

	cin>>n;

	for(int i=0;i<n;i++)
	{
		arr[i].numb=i;
		cin>>arr[i].a>>arr[i].b;
	}

	sort(arr,arr+n);
	bool flag=true;
	lastDay=arr[0].a;
	while(flag)
	{
		flag=false;
		for(int i=0;i<n;i++)
		{
			if(arr[i].u)
				continue;
			lastDay=max(lastDay,arr[i].a);
			arr[i].day=lastDay;
			arr[i].u=1;
			lastDay++;
			for(int j=0;j<n;j++)
				if(arr[j].a<lastDay && arr[j].b>=lastDay)
					arr[j].a=lastDay;
			sort(arr,arr+n);
			flag=true;
		}
	}

	for(int i=0;i<n;i++)
		for(int j=0;j<n;j++)
			if(arr[j].numb==i)
				cout<<arr[j].day<<" ";

	return 0;
}


#include <iostream>
#include <algorithm>

using namespace std;
class Data
{
public:
	int a,b,numb,day,u;
	bool operator<(const Data& rhs) const
	{
		if(a==rhs.a)
		{
			if(b<rhs.b)
				return true;
			else
				return false;
		}
		if(a<rhs.a)
			return true;
		return false;
	};
};
Data arr[200];
int main()
{
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);

	int n,lastDay=-1;

	cin>>n;

	for(int i=0;i<n;i++)
	{
		arr[i].numb=i;
		cin>>arr[i].a>>arr[i].b;
	}

	sort(arr,arr+n);
	bool flag=true;
	lastDay=arr[0].a;
	while(flag)
	{
		flag=false;
		for(int i=0;i<n;i++)
		{
			if(arr[i].u)
				continue;
			lastDay=max(lastDay,arr[i].a);
			arr[i].day=lastDay;
			arr[i].u=1;
			lastDay++;
			for(int j=0;j<n;j++)
				if(arr[j].a<lastDay && arr[j].b>=lastDay)
					arr[j].a=lastDay;
			sort(arr,arr+n);
			flag=true;
			break;
		}
	}

	for(int i=0;i<n;i++)
		for(int j=0;j<n;j++)
			if(arr[j].numb==i)
				cout<<arr[j].day<<" ";

	return 0;
}


#include <stdio.h>
#include <algorithm>
#include <string.h>
#include <vector>
#include <string>
#include <set>
#include <math.h>
using namespace std;
#define fin for (i=0; i<n; i++)
vector < pair < pair < int, int > , int > > a;
vector < pair < pair <int, int > , int > > b;
pair < pair < int, int > , int > q;
int w[150];
int n;
int main()
{
	scanf ("%d", &n);
	int i;
	for (i=0; i<n; i++)
	{
		scanf ("%d%d", &q.first.first, &q.first.second);
		q.second=i;
		a.push_back (q);
		swap (q.first.first, q.first.second);
		b.push_back(q);
	}
	sort (a.begin(), a.end());
	sort (b.begin(), b.end());
	n=a.size();
	int j, k, l=0, r=b[n-1].first.second, t, y, o, z;
	while (a.size()>0)
	{
		j=a.size()-1;
		if (b[j]>a[0])
		{

		}
			else
				if (b[j]<a[0])
				{

				}
					else
		{
			j--;
			if (j==-1)
			{
				w[a[0].second]=l+1;
				break;
			}
		}
		w[a[0].second]=max (a[0].first.first , l+1);
		l++;
		b[j].first.second=min (b[j].first.second, r);
		r=b[j].first.second-1;
		for (i=0; i<b.size(); i++)
		{
			z=0;
			if (a[0]>b[i])
				z=1;
			if (a[0]<b[i])
				z=1;
			if (z==0)
			{
				b.erase (b.begin()+i);
				break;
			}
		}
		a.erase (a.begin());
		/*for (i=0; i<a.size(); i++)
		{
			z=0;
			if (a[i]>b[j])
				z=1;
			if (a[i]<b[j])
				z=1;
			if (z==0)
			{
				a.erase (a.begin()+i);
				break;
			}
		}
		b.erase (b.begin()+j);*/
	}
	fin printf ("%d ", w[i]);
	return 0;
}


#include <stdio.h>
#include <algorithm>
#include <string.h>
#include <vector>
#include <string>
#include <math.h>
#include <utility>
using namespace std;
pair < int, int > a[100];
int n;
int main()
{
	scanf ("%d", &n);
	int i;
	for (i=0; i<n; i++)
	{
		scanf ("%d%d", &a[i].first, &a[i].second);
	}
	sort (a, a+n);
	i=0;
	int t=a[0].first;
	while (t<=a[n-1].second && i<n)
	{
		printf ("%d ", t);
		t=max (t+1, a[i+1].first);
		i++;
	}
	return 0;
}


#include <stdio.h>
#include <math.h>
#include <iostream>
#include <string.h>
#include <string>
#include <vector>
#include <set>
#include <utility>
#include <memory.h>
#include <algorithm>
using namespace std;
#define file "chimera"
#define fin for (i=0; i<n; i++)
typedef long long lint;
pair < pair < int, int > , int > a[100];
pair < pair < int, int > , int > q;
int w[150];
int n;
int c[10000500];
int main ()
{
scanf ("%d", &n);
int i;
for (i=0; i<n; i++)
{
scanf ("%d%d", &q.first.first, &q.first.second);
q.second=i;
a[i]=q;
}
sort (a, a+n);
int j;
for (i=n-1; i>=0; i--)
{
	j=a[i].first.second;
	while (c[j]==1)
	{
		j--;
	}
	if (j>=0)
	{
		c[j]=1;
		w[a[i].second]=j;
	}
}
for (i=0; i<n; i++)
printf ("%d ", w[i]);
return 0;
}


#include <stdio.h>
#include <algorithm>
#include <string.h>
#include <vector>
#include <string>
#include <math.h>
#include <utility>
using namespace std;
pair < int, int > a[150];
int n;
int main()
{
	scanf ("%d", &n);
	int i;
	for (i=0; i<n; i++)
	{
		scanf ("%d%d", &a[i].first, &a[i].second);
	}
	sort (a, a+n);
	i=0;
	int t=a[0].first;
	while (t<=a[n-1].second && i<n)
	{
		if (i==n-1)
		{
			printf ("%d", a[n-1].second);
			return 0;
		}
		printf ("%d ", t);
		t=max (t+1, a[i+1].first);
		i++;
	}
	return 0;
}


#define _CRT_SECURE_NO_DEPRECATE
#include <iostream>
#include <bitset>
#include <string>
#include <vector>
#include <algorithm>
#include <ctime>
#include <queue>
#include <cstring>
#include <set>
#include <map>
#include <sstream>
#include <cmath>
#include <fstream>
#include <list>
using namespace std;
#define rp(i,n) for(int (i)=0;(i)<(n);++(i))
#define pb push_back
#define L(s) (int)s.size()
#define mp make_pair
#define pii pair<int,int>
#define x first
#define y second
#define inf 1000000000
#define VI vector<int>
#define ll long long
#define all(s) (s).begin(),(s).end()
#define C(u) memset((u),0,sizeof((u)))
#define ull unsigned ll
struct T
{
	int x,y,n;
};
inline bool operator<(const T&a, const T&b)
{
	return mp(a.x,a.y)<mp(b.x,b.y);
}
vector< T > ev;
vector< T > cur;
int n;
int main()
{
	cin>>n;
	VI ans(n);
	rp(i,n)
	{
		T el;
		cin>>el.x>>el.y;
		el.n=i;
		ev.pb(el);
	}
	sort(all(ev));
	T el;
	el.x=el.y=el.n=inf;
	ev.pb(el);
	rp(i,n)
	{
		cur.pb(ev[i]);
		for(int tm=ev[i].x;tm<ev[i+1].x;++tm)
		{
			if (!L(cur))
				break;
			int best=0;
			rp(j,L(cur))
				if (cur[j].y-tm<cur[best].y-tm)
					best=j;
			ans[cur[best].n]=tm;
			cur.erase(cur.begin()+best);
		}
	}
	rp(i,L(ans))
	{
		if (i)
			cout<<" ";
		cout<<ans[i];
	}
	cout<<endl;
}


#define _CRT_SECURE_NO_DEPRECATE
#include <iostream>
#include <bitset>
#include <string>
#include <vector>
#include <algorithm>
#include <ctime>
#include <queue>
#include <cstring>
#include <set>
#include <map>
#include <sstream>
#include <cmath>
#include <fstream>
#include <list>
using namespace std;
#define rp(i,n) for(int (i)=0;(i)<(n);++(i))
#define pb push_back
#define L(s) (int)s.size()
#define mp make_pair
#define pii pair<int,int>
#define x first
#define y second
#define inf 1000000000
#define VI vector<int>
#define ll long long
#define all(s) (s).begin(),(s).end()
#define C(u) memset((u),0,sizeof((u)))
#define ull unsigned ll
vector< pii > ev;
vector< pii > cur;
VI ans;
int n;
int main()
{
	cin>>n;
	rp(i,n)
	{
		int p,q;
		cin>>p>>q;
		ev.pb(mp(p,q));
	}
	sort(all(ev));
	ev.pb(mp(inf,inf));
	rp(i,n)
	{
		cur.pb(ev[i]);
		for(int tm=ev[i].x;tm<ev[i+1].x;++tm)
		{
			if (!L(cur))
				break;
			int best=0;
			rp(j,L(cur))
				if (cur[j].y-tm<cur[best].y-tm)
					best=j;
			ans.pb(tm);
			cur.erase(cur.begin()+best);
		}
	}
	rp(i,L(ans))
	{
		if (i)
			cout<<" ";
		cout<<ans[i];
	}
	cout<<endl;
}


#include <iostream>
#include <stdio.h>
#include <vector>
#include <cmath>
#include <string>
#include <queue>
#include <set>
using namespace std;

struct otrez{
    int l,r,nom;
};

bool operator <(const otrez q,const otrez w){
    return q.l<w.l || (q.l==w.l && q.r<w.r);
}

vector <otrez> all;
multiset <otrez> now,spam;
multiset <otrez> :: iterator pos;
int n,l,r,ans[1000];

bool predicat(const otrez q,const otrez w){
    return q.l<w.l;
}

int main(){
    cin >> n;
    for (int i=0; i<n; i++)
    {
        cin >> l >> r;
        otrez p;
        p.l=l;
        p.r=r;
        p.nom=i;
        all.push_back(p);
    }
    sort(all.begin(),all.end(),predicat);
    for (int i=0; i<n; i++)
        now.insert(all[i]);
    for (int i=0; i<n; i++)
    {
        spam.clear();
        pos=now.begin();
        otrez del=*pos;
        ans[del.nom]=del.l;
        now.erase(pos);
        for (pos=now.begin(); pos!=now.end(); pos++)
        {
            otrez a=*pos;
            if (a.l==del.l) a.l++;
            spam.insert(a);
        }
        now=spam;
    }
    for (int i=0; i<n; i++)
        cout << ans[i] << " ";
}


/*
Author Starvae
www.starvae.com
starvae@gmail.com
2011.1.15

Today I wear the new underdress, warmful~
Thank you Seaco :) ~~

*/
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <iostream>
using namespace std;

const int N = 110;
const int M = 10000001;

int le[N],ri[N];
int n;

int Link[M];
int vis[M];
int ans[N];

int dfs(int u)
{
	for(int i = le[u];i<=ri[u];i++)
	{
		int v = i;
		if(vis[v] ) continue;
		vis[v] = 1;
		if(Link[v] == -1 || dfs(Link[v]))
		{
			Link[v] = u;
			ans[u] = v;
			return 1;
		}
	}
	return 0;
}

int main()
{
	scanf("%d",&n);
	memset(Link,-1,sizeof(Link));
	for(int i = 1;i<=n;i++)
	{
		scanf("%d%d",&le[i],&ri[i]);
		memset(vis,0,sizeof(vis));
		dfs(i);
	}
	for(int i = 1;i<=n;i++)
		printf("%d ",ans[i]);
	printf("\n");

	return 0;
}


/*
Author Starvae
www.starvae.com
starvae@gmail.com
2011.1.15

Today I wear the new underdress, warmful~
Thank you Seaco :) ~~

*/
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <iostream>
using namespace std;

const int N = 110;
const int M = 10000001;

int le[N],ri[N];
int n;

int Link[M];
int vis[M];
int ans[N];
int num;
int dfs(int u)
{
	for(int i = le[u];i<=ri[u];i++)
	{
		int v = i;
		if(vis[v] == num ) continue;
		vis[v] = num;
		if(Link[v] == -1 || dfs(Link[v]))
		{
			Link[v] = u;
			ans[u] = v;
			return 1;
		}
	}
	return 0;
}

int main()
{
	scanf("%d",&n);
	memset(Link,-1,sizeof(Link));
	for(int i = 1;i<=n;i++)
	{
		num = i;
		scanf("%d%d",&le[i],&ri[i]);
	//	memset(vis,0,sizeof(vis));
		dfs(i);
	}
	for(int i = 1;i<=n;i++)
		printf("%d ",ans[i]);
	printf("\n");

	return 0;
}


/*#include<iostream>
#include<algorithm>
using namespace std;
struct node
{
	int t;
	double p;
	bool operator < (node &nn)const
	{
		if(t==nn.t)
		{
			return p>nn.p;
		}
		return t<nn.t;
	}
};
node pp[1001];
int main()
{
	int x,y,i,j,n,maxt,pret;
	double al;
	freopen("a.txt","r",stdin);
	while( scanf("%d",&n)!=EOF )
	{
		maxt=-1;
		for(i=0;i<n;i++)
		{
			scanf("%d%d%d%lf",&x,&y,&pp[i].t,&pp[i].p);
			//if( pp[i].t>maxt)maxt=pp[i].t;
		}
		sort(pp,pp+n);
        al=0;
		//cout<<maxt<<endl;
		pret=pp[0].t;
		al+=pp[0].p;
		for(i=1;i<n;i++)
		{
			if(pp[i].t!=pret)
			{
				pret=pp[i].t;
				al+=pp[i].p;
			}
			//if(maxt<0)break;
		}
		printf("%.10lf\n",al);
	}
	return 0;
}
*/
/*
#include<iostream>
#include<string>
using namespace std;
string str[12]={  "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"    };
int main()
{
	int i,j,num;
	string str1;

	//freopen("w.txt","r",stdin);
	while(cin>>str1>>num)
	{
		num%=12;
		for(i=0;i<12;i++)
		{
			if(str1==str[i])break;
		}
		num+=i;
		num%=12;
	    cout<<str[num]<<endl;
	}
	return 0;
}*/
#include<iostream>
#include<algorithm>
using namespace std;
struct num
{
	int st,end,index;
	bool operator <(num& nn)
	{
		if(nn.st==st)
		{
			return end<nn.end;
		}
		else return st<nn.st;
	}
};
num p[101];
bool cmp1(num n1,num n2)
{
	if(n1.st==n2.st)return n1.end<n2.end;
	else return n1.st<n2.st;
}
bool cmp2(num n1,num n2)
{
	return n1.index<n2.index;
}
int main()
{
	int i,j,k,n;
	//freopen("g.txt","r",stdin);
	while(scanf("%d",&n)!=EOF)
	{
		for(i=0;i<n;i++)
		{
			scanf("%d%d",&p[i].st,&p[i].end);
			p[i].index=i;
		}
		sort(p,p+n,cmp1);
		for(i=0;i<n;i++)
		{

			if(i==n-1)break;
			for(j=i+1;j<n;j++)
			{
				if(p[j].st==p[i].st)
					p[j].st++;
				else break;
			}
			sort(p+i+1,p+n,cmp1);
		}
		sort(p,p+n,cmp2);
			for(i=0;i<n;i++)
			{
				printf("%d",p[i].st);
				if(i<n-1)printf(" ");
				else printf("\n");
			}
	}
	return 0;
}


/*#include<iostream>
#include<algorithm>
using namespace std;
struct node
{
	int t;
	double p;
	bool operator < (node &nn)const
	{
		if(t==nn.t)
		{
			return p>nn.p;
		}
		return t<nn.t;
	}
};
node pp[1001];
int main()
{
	int x,y,i,j,n,maxt,pret;
	double al;
	freopen("a.txt","r",stdin);
	while( scanf("%d",&n)!=EOF )
	{
		maxt=-1;
		for(i=0;i<n;i++)
		{
			scanf("%d%d%d%lf",&x,&y,&pp[i].t,&pp[i].p);
			//if( pp[i].t>maxt)maxt=pp[i].t;
		}
		sort(pp,pp+n);
        al=0;
		//cout<<maxt<<endl;
		pret=pp[0].t;
		al+=pp[0].p;
		for(i=1;i<n;i++)
		{
			if(pp[i].t!=pret)
			{
				pret=pp[i].t;
				al+=pp[i].p;
			}
			//if(maxt<0)break;
		}
		printf("%.10lf\n",al);
	}
	return 0;
}
*/
/*
#include<iostream>
#include<string>
using namespace std;
string str[12]={  "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"    };
int main()
{
	int i,j,num;
	string str1;

	//freopen("w.txt","r",stdin);
	while(cin>>str1>>num)
	{
		num%=12;
		for(i=0;i<12;i++)
		{
			if(str1==str[i])break;
		}
		num+=i;
		num%=12;
	    cout<<str[num]<<endl;
	}
	return 0;
}*/
#include<iostream>
#include<algorithm>
using namespace std;
struct num
{
	int st,end;
	bool operator <(num& nn)
	{
		if(nn.st==st)
		{
			return end<nn.end;
		}
		else return st<nn.st;
	}
};
num p[101];
int main()
{
	int i,j,k,n;
	//freopen("g.txt","r",stdin);
	while(scanf("%d",&n)!=EOF)
	{
		for(i=0;i<n;i++)
		{
			scanf("%d%d",&p[i].st,&p[i].end);
		}
		sort(p,p+n);
		for(i=0;i<n;i++)
		{
			printf("%d",p[i].st);
			if(i<n-1)printf(" ");
			else
			{
				printf("\n");
				break;
			}
			for(j=i+1;j<n;j++)
			{
				if(p[j].st==p[i].st)
					p[j].st++;
				else break;
			}
			sort(p+i+1,p+n);
		}
	}
	return 0;
}


/*#include<iostream>
#include<algorithm>
using namespace std;
struct node
{
	int t;
	double p;
	bool operator < (node &nn)const
	{
		if(t==nn.t)
		{
			return p>nn.p;
		}
		return t<nn.t;
	}
};
node pp[1001];
int main()
{
	int x,y,i,j,n,maxt,pret;
	double al;
	freopen("a.txt","r",stdin);
	while( scanf("%d",&n)!=EOF )
	{
		maxt=-1;
		for(i=0;i<n;i++)
		{
			scanf("%d%d%d%lf",&x,&y,&pp[i].t,&pp[i].p);
			//if( pp[i].t>maxt)maxt=pp[i].t;
		}
		sort(pp,pp+n);
        al=0;
		//cout<<maxt<<endl;
		pret=pp[0].t;
		al+=pp[0].p;
		for(i=1;i<n;i++)
		{
			if(pp[i].t!=pret)
			{
				pret=pp[i].t;
				al+=pp[i].p;
			}
			//if(maxt<0)break;
		}
		printf("%.10lf\n",al);
	}
	return 0;
}
*/
/*
#include<iostream>
#include<string>
using namespace std;
string str[12]={  "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"    };
int main()
{
	int i,j,num;
	string str1;

	//freopen("w.txt","r",stdin);
	while(cin>>str1>>num)
	{
		num%=12;
		for(i=0;i<12;i++)
		{
			if(str1==str[i])break;
		}
		num+=i;
		num%=12;
	    cout<<str[num]<<endl;
	}
	return 0;
}*/
#include<iostream>
#include<algorithm>
using namespace std;
struct num
{
	int st,end;
	bool operator <(num& nn)
	{
		if(nn.st==st)
		{
			return end<nn.end;
		}
		else return st<nn.st;
	}
};
num p[101];
int main()
{
	int i,j,k,n;
	//freopen("g.txt","r",stdin);
	while(scanf("%d",&n)!=EOF)
	{
		for(i=0;i<n;i++)
		{
			scanf("%d%d",&p[i].st,&p[i].end);
		}
		sort(p,p+n);
		for(i=0;i<n;i++)
		{
			printf("%d",p[i].st);
			if(i<n-1)printf(" ");
			else printf("\n");
			for(j=i+1;j<n;j++)
			{
				if(p[j].st==p[i].st)
					p[j].st++;
				else break;
			}
			sort(p+i+1,p+n);
		}
	}
	return 0;
}


#include <iostream>
#include <set>
#include <algorithm>
#include <cstdio>

using namespace std;

struct point{
        int x,y,z;
};

const int nmax=100+10;
point a[nmax];
int n,top,soluu,cha,con;
int ans[nmax];
int s[nmax],vt[nmax];
//........................
bool f(point x,point y){
        if(x.x!=y.x)
                return x.x<y.x;
        else
                return x.y<y.y;
}
void solve();
void them(int u);
long lay();
//........................
int main(){
        //freopen("baiD.txt","r",stdin);
        //freopen("BaiD.out","w",stdout);
        cin >> n;
        int i,j;
        for(i=1;i<=n;i++){
                cin >> a[i].x >> a[i].y;
                a[i].z=i;
        }
        sort(a+1,a+n+1,f);
        solve();
        for (i=1;i<=n;i++) printf("%ld ",ans[i]);
        //...................
        return 0;
}

void them(int u)
{
     top++;
     int v;
     cha=top;
     while (cha>>1>0)
     {
           con=cha>>1;
           if (a[s[con]].y<=a[u].y) break;
           s[cha]=s[con];
     }
     s[cha]=u;
}

long lay()
{
     long w;
     w=s[1];
     top--;
     if (top==0) return w;
     int u,v;
     cha=1;
     u=s[top+1];
     while (cha<<1<=top)
     {
           con=cha<<1;
           if (a[s[con]].y>a[s[con+1]].y) con++;
           if (a[u].y<=a[s[con]].y) break;
           s[cha]=s[con];
     }
     s[cha]=u;
     return w;
}

void solve()
{    long j,i,u,k;
     top=0;
     k=0;
     soluu=0;
     for (i=1;i<=n;i++)
     {
         if (top==0)
         {
         k=a[soluu+1].x;
             for (j=soluu+1;j<=n;j++)
             {
                 if (a[j].x!=k) break;
                 them(j);
                 soluu=j;
             }
         }
         u=lay();
         ans[a[u].z]=k++;
         while (a[soluu+1].x<=k&& soluu+1<=n) them(++soluu);
     }
}


#include <iostream>
#include <set>
#include <algorithm>
#include <cstdio>

using namespace std;

struct point{
        long x,y,z;
};

const int nmax=100+10;
point a[nmax];
long n,top,soluu;
long ans[nmax];
long s[nmax],vt[nmax];
//........................
bool f(point x,point y){
        if(x.x!=y.x)
                return x.x<y.x;
        else
                return x.y<y.y;
}
void solve();
void them(long u);
long lay();
//........................
int main(){
        //freopen("baiD.txt","r",stdin);
        //freopen("BaiD.out","w",stdout);
        cin >> n;
        long i,j;
        for(i=1;i<=n;i++){
                cin >> a[i].x >> a[i].y;
                a[i].z=i;
        }
        sort(a+1,a+n+1,f);
        solve();
        for (i=1;i<=n;i++) printf("%ld ",ans[i]);
        //...................
        return 0;
}

void them(long u)
{
     top++;
     long v,cha,con;
     cha=top;
     while (cha/2>0)
     {
           con=cha/2;
           if (a[s[con]].y<=a[u].y) break;
           s[cha]=s[con];
           //vt[s[con]]=cha;
     }
     s[cha]=u;
     //vt[u]=cha;
}

long lay()
{
     long w;
     w=s[1];
     top--;
     if (top==0) return w;
     long u,v,cha,con;
     cha=1;
     u=s[top+1];
     while (cha*2<=top)
     {
           con=cha*2;
           if (a[s[con]].y>a[s[con+1]].y) con++;
           if (a[u].y<=a[s[con]].y) break;
           s[cha]=s[con];
           //vt[s[con]]=cha;
     }
     s[cha]=u;
}

void solve()
{    long j,i,u,k;
     top=0;
     k=0;
     soluu=0;
     for (i=1;i<=n;i++)
     {
         if (top==0)
         {
         k=a[soluu+1].x;
             for (j=soluu+1;j<=n;j++)
             {
                 if (a[j].x!=k) break;
                 them(j);
                 soluu=j;
             }
         }
         u=lay();
         ans[a[u].z]=k++;
         while (a[soluu+1].x<=k&& soluu+1<=n) them(++soluu);
     }
}


#include <iostream>
#include <set>
#include <algorithm>
#include <cstdio>

using namespace std;

struct point{
        int x,y,z;
};

const int nmax=100+10;
point a[nmax];
int n,top,soluu;
int ans[nmax];
int s[nmax],vt[nmax];
//........................
bool f(point x,point y){
        if(x.x!=y.x)
                return x.x<y.x;
        else
                return x.y<y.y;
}
void solve();
void them(int u);
long lay();
//........................
int main(){
        //freopen("baiD.txt","r",stdin);
        //freopen("BaiD.out","w",stdout);
        cin >> n;
        int i,j;
        for(i=1;i<=n;i++){
                cin >> a[i].x >> a[i].y;
                a[i].z=i;
        }
        sort(a+1,a+n+1,f);
        solve();
        for (i=1;i<=n;i++) printf("%ld ",ans[i]);
        //...................
        return 0;
}

void them(int u)
{
     top++;
     int v,cha,con;
     cha=top;
     while (cha/2>0)
     {
           con=cha/2;
           if (a[s[con]].y<=a[u].y) break;
           s[cha]=s[con];
     }
     s[cha]=u;
}

long lay()
{
     long w;
     w=s[1];
     top--;
     if (top==0) return w;
     int u,v,cha,con;
     cha=1;
     u=s[top+1];
     while (cha*2<=top)
     {
           con=cha*2;
           if (a[s[con]].y>a[s[con+1]].y) con++;
           if (a[u].y<=a[s[con]].y) break;
           s[cha]=s[con];
     }
     s[cha]=u;
     return w;
}

void solve()
{    long j,i,u,k;
     top=0;
     k=0;
     soluu=0;
     for (i=1;i<=n;i++)
     {
         if (top==0)
         {
         k=a[soluu+1].x;
             for (j=soluu+1;j<=n;j++)
             {
                 if (a[j].x!=k) break;
                 them(j);
                 soluu=j;
             }
         }
         u=lay();
         ans[a[u].z]=k++;
         while (a[soluu+1].x<=k&& soluu+1<=n) them(++soluu);
     }
}


#include<iostream>
#include<cstdlib>
#include<cstdio>
#include<cstring>
//..................
void swap(long *x,long *y);
//..................
int main()
{
    //freopen("D.txt","r",stdin);
    //freopen("D.out","w",stdout);
    long n;
    long l[111],r[111],vt[111];
    long u,v,i,j;
    long ans[111];
    scanf("%ld\n",&n);
    for (i=1;i<=n;i++)
    {
        scanf("%ld%ld\n",&u,&v);
        l[i]=u;
        r[i]=v;
        vt[i]=i;
    }
    for (i=1;i<n;i++)
      for (j=i+1;j<=n;j++)
      if (r[i]>r[j] || (r[i]==r[j] && l[i]>l[j]))
      {
          swap(&r[i],&r[j]);
          swap(&l[i],&l[j]);
          swap(&vt[i],&vt[j]);
      }
    j=0;
    for (i=1;i<=n;i++)
    {
        if (j<l[i]) j=l[i];
        ans[vt[i]]=j;
        j++;
    }
    for (i=1;i<=n;i++) printf("%ld ",ans[i]);
    return 0;
}

void swap(long *x,long *y)
{
     long tmp;
     tmp=*x;
     *x=*y;
     *y=tmp;
}


#include <iostream>
#include <set>
#include <algorithm>
#include <cstdio>

using namespace std;

struct polong{
        long x,y,z;
};

const long nmax=100+10;
polong a[nmax];
long n,top,soluu,cha,con;
long ans[nmax];
long s[nmax],vt[nmax];
//........................
bool f(polong x,polong y){
        if(x.x!=y.x)
                return x.x<y.x;
        else
                return x.y<y.y;
}
void solve();
void them(long u);
long lay();
//........................
int main(){
        //freopen("D.inp","r",stdin);
        //freopen("D2.txt","w",stdout);
        cin >> n;
        long i,j;
        for(i=1;i<=n;i++){
                cin >> a[i].x >> a[i].y;
                a[i].z=i;
        }
        sort(a+1,a+n+1,f);
        solve();
        for (i=1;i<=n;i++) printf("%ld ",ans[i]);
        //...................
        return 0;
}

void them(long u)
{
     top++;
     long v;
     cha=top;
     while (cha>>1>0)
     {
           con=cha>>1;
           if (a[s[con]].y<=a[u].y) break;
           s[cha]=s[con];
           cha=con;
     }
     s[cha]=u;
}

long lay()
{

     long w;
     w=s[1];
     top--;
     if (top==0) return w;
     long u,v;
     cha=1;
     u=s[top+1];
     while (cha<<1<=top)
     {
           con=cha<<1;
           if (a[s[con]].y>a[s[con+1]].y) con++;
           if (a[u].y<=a[s[con]].y) break;
           s[cha]=s[con];
           cha=con;
     }
     s[cha]=u;
     return w;
}

void solve()
{    long j,i,u,k;
     top=0;
     k=0;
     soluu=0;
     for (i=1;i<=n;i++)
     {
         if (top==0 && soluu<n)
         {
         k=a[soluu+1].x;
             for (j=soluu+1;j<=n;j++)
             {
                 if (a[j].x!=k) break;
                 them(j);
                 soluu=j;
             }
         }
         u=lay();
         ans[a[u].z]=k++;
         while (a[soluu+1].x<=k&& soluu+1<=n) them(++soluu);
     }
}


#include <iostream>
#include <set>
#include <algorithm>
#include <cstdio>

using namespace std;

struct polong{
        long x,y,z;
};

const long nmax=100+10;
polong a[nmax];
long n,top,soluu,cha,con;
long ans[nmax];
long s[nmax],vt[nmax];
//........................
bool f(polong x,polong y){
        if(x.x!=y.x)
                return x.x<y.x;
        else
                return x.y<y.y;
}
void solve();
void them(long u);
long lay();
//........................
int main(){
        //freopen("D.inp","r",stdin);
        //freopen("D2.txt","w",stdout);
        cin >> n;
        long i,j;
        for(i=1;i<=n;i++){
                cin >> a[i].x >> a[i].y;
                a[i].z=i;
        }
        sort(a+1,a+n+1,f);
        solve();
        for (i=1;i<=n;i++) printf("%ld ",ans[i]);
        //...................
        return 0;
}

void them(long u)
{
     top++;
     long v;
     cha=top;
     while (cha>>1>0)
     {
           con=cha>>1;
           if (a[s[con]].y<=a[u].y) break;
           s[cha]=s[con];
           cha=con;
     }
     s[cha]=u;
}

long lay()
{
     long w;
     w=s[1];
     top--;
     if (top==0) return w;
     long u,v;
     cha=1;
     u=s[top+1];
     while (cha<<1<=top)
     {
           con=cha<<1;
           if (a[s[con]].y>a[s[con+1]].y) con++;
           if (a[u].y<=a[s[con]].y) break;
           s[cha]=s[con];
           cha=con;
     }
     s[cha]=u;
     return w;
}

void solve()
{    long j,i,u,k;
     top=0;
     k=0;
     soluu=0;
     for (i=1;i<=n;i++)
     {
         if (top==0 && soluu<n)
         {
         k=a[soluu+1].x;
             for (j=soluu+1;j<=n;j++)
             {
                 if (a[j].x!=k) break;
                 them(j);
                 soluu=j;
             }
         }
         u=lay();
         ans[a[u].z]=k++;
         while (a[soluu+1].x<=k&& soluu+1<=n) them(++soluu);
     }
}


#include<iostream>
#include<cstdlib>
#include<cstdio>
#include<cstring>
//..................
void swap(long *x,long *y);
//..................
int main()
{
    //freopen("D.txt","r",stdin);
    //freopen("D.out","w",stdout);
    long n;
    long l[111],r[111],vt[111];
    long u,v,i,j;
    long ans[111];
    scanf("%ld\n",&n);
    for (i=1;i<=n;i++)
    {
        scanf("%ld%ld\n",&u,&v);
        l[i]=u;
        r[i]=v;
        vt[i]=i;
    }
    for (i=1;i<n;i++)
      for (j=i+1;j<=n;j++)
      if ((l[i]>l[j]) || (l[i]==l[j] && r[i]>r[j]))
      {
          swap(&r[i],&r[j]);
          swap(&l[i],&l[j]);
          swap(&vt[i],&vt[j]);
      }
    j=0;
    for (i=1;i<=n;i++)
    {
        if (j<l[i]) j=l[i];
        ans[vt[i]]=j;
        j++;
    }
    for (i=1;i<=n;i++) printf("%ld ",ans[i]);
    return 0;
}

void swap(long *x,long *y)
{
     long tmp;
     tmp=*x;
     *x=*y;
     *y=tmp;
}


#include <iostream>
#include <algorithm>
using namespace std;
#define MAX 10000005
struct node
{
	int s,e;
	int len;
	int id;
};
node mm[105];
int cmp(node a,node b)
{
	if(a.s==b.s)return a.len<b.len;
	return a.s<b.s;
}
int cmp2(node a,node b)
{
	return a.id<b.id;
}
int ans[105];
int main ()
{
	int n;
	int i,j;
	while(scanf("%d",&n)!=EOF)
	{
		for(i=0;i<n;i++)
		{
			scanf("%d%d",&mm[i].s,&mm[i].e);
			mm[i].len=mm[i].e-mm[i].s+1;
			mm[i].id=i;
		}
		for(i=0;i<n;i++)
		{
			sort(mm,mm+n,cmp);
			ans[mm[0].id]=mm[0].s;
			for(j=1;j<n;j++)
			{
				if(mm[j].s==mm[0].s)
				{
					mm[j].s++;
					mm[j].len--;
				}
				else break;
			}
			mm[0].s=MAX;
		}
		for(i=0;i<n-1;i++)printf("%d ",ans[i]);
		printf("%d\n",ans[i]);
	}
	return 0;
}


#include <iostream>
using namespace std;
struct node
{
	int s,e;
};
node mm[105];
int cmp(node a,node b)
{
	if(a.s==b.s)return a.e<b.e;
	return a.s<b.s;
}
int ans[105];
int main ()
{
	int n;
	int i,last;
	while(scanf("%d",&n)!=EOF)
	{
		for(i=0;i<n;i++)
		{
			scanf("%d%d",&mm[i].s,&mm[i].e);
		}
		sort(mm,mm+n,cmp);
		last=0;
		for(i=0;i<n;i++)
		{
			if(mm[i].s>last)
			{
				last=mm[i].s;
			}
			else last++;
			ans[i]=last;
		}
		for(i=0;i<n-1;i++)printf("%d ",ans[i]);
		printf("%d\n",ans[i]);
	}
	return 0;
}


#include <iostream>
#include <algorithm>
using namespace std;
struct node
{
	int s,e;
};
node mm[105];
int cmp(node a,node b)
{
	if(a.s==b.s)return a.e<b.e;
	return a.s<b.s;
}
int ans[105];
int main ()
{
	int n;
	int i,last;
	while(scanf("%d",&n)!=EOF)
	{
		for(i=0;i<n;i++)
		{
			scanf("%d%d",&mm[i].s,&mm[i].e);
		}
		sort(mm,mm+n,cmp);
		last=0;
		for(i=0;i<n;i++)
		{
			if(mm[i].s>last)
			{
				last=mm[i].s;
			}
			else last++;
			ans[i]=last;
		}
		for(i=0;i<n-1;i++)printf("%d ",ans[i]);
		printf("%d\n",ans[i]);
	}
	return 0;
}


#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
using namespace std;
int main()
{
    long long n,i,j;
    cin>>n;
    vector<pair<pair<long ,long>,long> >v(n);
    set<pair<long,long> > date;
    set<long> use;
    for(i=0;i<n;i++) {cin>>v[i].first.first>>v[i].first.second; v[i].second=i;}
    sort(v.begin(),v.end());
    for(i=0;i<n;i++)
    {
        long long l=v[i].first.first,r=v[i].first.second,nom=v[i].second;
        for(j=l;j<=r;j++)
        {
            pair<set<long>::iterator,bool> temp=use.insert(j);
            if(temp.second)
            {
                date.insert(make_pair(nom,j));
                break;
            }
        }
    }
    for(set<pair<long,long> >::iterator it=date.begin();it!=date.end();it++) cout<<it->second<<' ';
}


#include <iostream>
using namespace std;
#include <algorithm>

struct otrezok{
    long begin,end;
    bool operator < (otrezok &s){
        return s.begin>begin;}
} ;
int main(){
    otrezok a[1000];
    long n,i,j,k[10000],l,o=1,d;
    bool flag;
    cin>>n;
    for(i=0;i<n;i++)cin>>a[i].begin>>a[i].end;
    sort(&a[0],&a[n]);
    k[0]=a[0].begin;

    for(i=1;i<n;i++){
        flag=true;
        for(j=a[i].begin;j<=a[i].end;j++){
            if(flag==false)break;
            for(l=0;l<i;l++){
                if(k[l]!=j){
                    k[i]=j;
                    flag=false;break;
                }
            }

        }

    }
    for(i=0;i<n;i++){
        cout<<k[i]<<' ';
    }

}


#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <stack>
using namespace std;
int main()
{
    long long n,i,j,l,r;
    cin>>n;
    set<pair<pair<long ,long>,long> >v;
    //set<pair<long,long> > date;
    set<long> use;
    for(i=0;i<n;i++) {cin>>l>>r; v.insert(make_pair(make_pair(l,r),i));}
    while(!v.empty())
    {
        pair<long,long> t=v.begin()->first;
        long nomb=v.begin()->second;
        v.erase(v.begin());
        long l=t.first,r=t.second;
            pair<set<long>::iterator,bool> temp=use.insert(l);
            if(!temp.second)
            {
                //date.insert(make_pair(nom,j));
                v.insert(make_pair(make_pair(l+1,r),nomb));

            }
    }
    stack<long> q;
    for(set<long>::iterator it=use.begin();it!=use.end();it++) q.push(*it);
    while(!q.empty())
    {
        cout<<q.top()<<' ';
        q.pop();
    }
}


#include <iostream>
using namespace std;
#include <algorithm>

struct otrezok{
    long begin,end;
    bool operator < (otrezok &s){
        return s.begin>begin;}
} ;
int main(){
    otrezok a[1000];
    long n,i,j,k[10000],l,o=1,d;
    bool flag;
    cin>>n;
    for(i=0;i<n;i++)cin>>a[i].begin>>a[i].end;
    sort(&a[0],&a[n]);
    k[0]=a[0].begin;

    for(i=1;i<n;i++){
        flag=true;
        for(j=a[i].begin;j<=a[i].end;j++){
            if(flag=true){
                for(l=0;l<i;l++)
                    if(j==k[l]){
                        flag=false;
                        break;

                    }

                if (flag==true){
                    k[i]=j;flag=false;
                }

            }else break;

        }

    }
    for(i=0;i<n;i++){
        cout<<k[i]<<' ';
    }

}


#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
using namespace std;
int main()
{
    long long n,i,j;
    cin>>n;
    vector<pair<pair<long ,long>,long> >v(n);
    set<pair<long,long> > date;
    set<long> use;
    for(i=0;i<n;i++) {cin>>v[i].first.first>>v[i].first.second; v[i].second=i;}
    sort(v.begin(),v.end());
    for(i=0;i<n;i++)
    {
        long long l=v[i].first.first,r=v[i].first.second,nom=v[i].second;
        for(j=l;j<=r;j++)
        {
            pair<set<long>::iterator,bool> temp=use.insert(j);
            if(temp.second)
            {
                date.insert(make_pair(nom,j));
                break;
            }
        }
    }
    for(set<long>::iterator it=use.begin();it!=use.end();it++) cout<<*it<<' ';
}


#include <iostream>
using namespace std;
#include <algorithm>

struct otrezok{
    long begin,end;
    bool operator < (otrezok &s){
        return s.begin>begin;}
} ;
int main(){
    otrezok a[1000];
    long long n,i,j,k[10000],l,o=1,d,temp;
    bool flag;
    cin>>n;
    for(i=0;i<n;i++)cin>>a[i].begin>>a[i].end;
    /*for(i=0;i<n;i++)
        for(j=i;j<n;j++){
            if(a[i].begin<a[j].begin){
                temp=a[i].begin;
                a[i].begin=a[j].begin;
                a[j].begin=temp;
                temp=a[i].end;
                a[i].end=a[j].end;
                a[j].end=temp;
            }
            if(a[i].begin<a[j].begin){
                temp=a[i].begin;
                a[i].begin=a[j].begin;
                a[j].begin=temp;
                temp=a[i].end;
                a[i].end=a[j].end;
                a[j].end=temp;
            }

        }*/

    k[0]=a[0].begin;

    for(i=1;i<n;i++){
        flag=true;
        for(j=a[i].begin;j<=a[i].end;j++){
            if(flag==false)break;
            o=0;
            for(l=0;l<i;l++){
                if(k[l]==j)o--;}
            if(o==0){k[i]=j;flag=false;}

        }

    }

    for(i=0;i<n;i++){
        cout<<k[i]<<' ';
    }

}


#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <stack>
using namespace std;
int main()
{
	long long n,i,j,l,r;
	cin>>n;
	set<pair<pair<long ,long>,long> >v;
	//set<pair<long,long> > date;
	stack<pair<long,long> > use;
	for(i=0;i<n;i++) {cin>>l>>r; v.insert(make_pair(make_pair(l,r),i));}
	while(!v.empty())
	{
		pair<long,long> t=v.begin()->first;
		long nomb=v.begin()->second;
		v.erase(v.begin());
		long l=t.first,r=t.second;
		if(use.empty()||use.top().first!=l)
			{
				//date.insert(make_pair(nom,j));
				use.push(make_pair(l,nomb));
				//v.insert(make_pair(make_pair(l+1,r),nomb));

			}
		else{
			v.insert(make_pair(make_pair(l+1,r),nomb));
		}
	}
	set<pair<long,long> >q;
	while(!use.empty()){
		q.insert(make_pair(use.top().second,use.top().first));
		use.pop();}
	for(set<pair<long,long> >::iterator it=q.begin();it!=q.end();it++) cout<<it->second<<' ';
}


#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
using namespace std;
int main()
{
    long long n,i,j,l,r;
    cin>>n;
    set<pair<pair<long ,long>,long> >v;
    //set<pair<long,long> > date;
    set<long> use;
    for(i=0;i<n;i++) {cin>>l>>r; v.insert(make_pair(make_pair(l,r),i));}
    while(!v.empty())
    {
        pair<long,long> t=v.begin()->first;
        long nomb=v.begin()->second;
        v.erase(v.begin());
        long l=t.first,r=t.second;
            pair<set<long>::iterator,bool> temp=use.insert(l);
            if(!temp.second)
            {
                //date.insert(make_pair(nom,j));
                v.insert(make_pair(make_pair(l+1,r),nomb));

            }
    }
    for(set<long>::iterator it=use.begin();it!=use.end();it++) cout<<*it<<' ';
}


#include <iostream>
using namespace std;
#include <algorithm>

struct otrezok{
    long begin,end;
    bool operator < (otrezok &s){
        return s.end>end;}
} ;
int main(){
    otrezok a[1000];
    long n,i,j,k[10000],l,o=1,d;
    bool flag;
    cin>>n;
    for(i=0;i<n;i++)cin>>a[i].begin>>a[i].end;
    sort(&a[0],&a[n]);
    k[0]=a[0].begin;

    for(i=1;i<n;i++){
        flag=true;
        for(j=a[i].begin;j<=a[i].end;j++){
            if(flag==false)break;
            for(l=0;l<i;l++){
                if(k[l]!=j){
                    k[i]=j;
                    flag=false;break;
                }
            }

        }

    }
    for(i=0;i<n;i++){
        cout<<k[i]<<' ';
    }

}


#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <iostream>
#include <complex>
using namespace std;
#define pb push_back

char c[10000005];
pair<pair<int, int>, int > pr[105];
int ans[105];

int main()
{
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    int n, i, j;
    cin >> n;
    for(i=0; i<n; i++)
    {
        cin >> pr[i].first.second >> pr[i].first.first;
        pr[i].second=i;
    }
    sort(pr, pr+n);
    for(i=0; i<n; i++)
        for(j=pr[i].first.second; ; j++)
            if (!c[j])
            {
                c[j]=1;
                ans[pr[i].second]=j;
                break;
            }
    for(i=0; i<n; i++)
        cout << ans[i]  << " ";
}


#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <sstream>
#include <cmath>
#include <cassert>
#include <memory.h>

using namespace std;

#define pb push_back
#define mp make_pair
#define sz(a) (int)(a).size()
#define _(a,b) memset((a), (b), sizeof(a))

void prepare()
{
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
#endif
}

int n;
pair<pair<int, int>, int> a[105];
set<int> se;

bool ms(const pair<pair<int, int>, int> &a, const pair<pair<int, int>, int> &b)
{
	return a.first.second - a.first.first < b.first.second - b.first.first;
}

int res[105];

void solve()
{
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> a[i].first.first >> a[i].first.second;
		a[i].second = i;
	}
	sort(a, a + n, ms);
	for (int i = 0; i < n; i++)
	{
		int k = a[i].first.first;
		while (se.find(k) != se.end())
			k++;
		res[a[i].second] = k;
		se.insert(k);
	}
	for (int i = 0; i < n; i++)
		printf("%d ", res[i]);
}

int main()
{
	prepare();
	solve();
	return 0;
}


#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <sstream>
#include <cmath>
#include <cassert>
#include <memory.h>

using namespace std;

#define pb push_back
#define mp make_pair
#define sz(a) (int)(a).size()
#define _(a,b) memset((a), (b), sizeof(a))

void prepare()
{
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
#endif
}

int n;
pair<pair<int, int>, int> a[105];
set<int> se;

bool ms(const pair<pair<int, int>, int> &a, const pair<pair<int, int>, int> &b)
{
	return a.first.second < b.first.second;
	return a.first.second - a.first.first < b.first.second - b.first.first ||
		a.first.second - a.first.first == b.first.second - b.first.first &&
		a.first.second < b.first.second;
}

int res[105];

void solve()
{
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> a[i].first.first >> a[i].first.second;
		a[i].second = i;
	}
	sort(a, a + n, ms);
	for (int i = 0; i < n; i++)
	{
		int k = a[i].first.first;
		while (se.find(k) != se.end())
			k++;
		res[a[i].second] = k;
		se.insert(k);
	}
	for (int i = 0; i < n; i++)
		printf("%d ", res[i]);
}

int main()
{
	prepare();
	solve();
	return 0;
}


#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <sstream>
#include <cmath>
#include <cassert>
#include <memory.h>

using namespace std;

#define pb push_back
#define mp make_pair
#define sz(a) (int)(a).size()
#define _(a,b) memset((a), (b), sizeof(a))

void prepare()
{
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
#endif
}

int n;
pair<pair<int, int>, int> a[105];
set<int> se;

bool ms(const pair<pair<int, int>, int> &a, const pair<pair<int, int>, int> &b)
{
	return a.first.second - a.first.first < b.first.second - b.first.first ||
		a.first.second - a.first.first == b.first.second - b.first.first &&
		a.first.first < b.first.first;
}

int res[105];

void solve()
{
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> a[i].first.first >> a[i].first.second;
		a[i].second = i;
	}
	sort(a, a + n, ms);
	for (int i = 0; i < n; i++)
	{
		int k = a[i].first.first;
		while (se.find(k) != se.end())
			k++;
		res[a[i].second] = k;
		se.insert(k);
	}
	for (int i = 0; i < n; i++)
		printf("%d ", res[i]);
}

int main()
{
	prepare();
	solve();
	return 0;
}


#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <sstream>
#include <cmath>
#include <cassert>
#include <memory.h>

using namespace std;

#define pb push_back
#define mp make_pair
#define sz(a) (int)(a).size()
#define _(a,b) memset((a), (b), sizeof(a))

void prepare()
{
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
#endif
}

int n;
pair<pair<int, int>, int> a[105];
set<int> se;

bool ms(const pair<pair<int, int>, int> &a, const pair<pair<int, int>, int> &b)
{
	return a.first.second - a.first.first < b.first.second - b.first.first ||
		a.first.second - a.first.first == b.first.second - b.first.first &&
		a.first.second < b.first.second;
}

int res[105];

void solve()
{
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> a[i].first.first >> a[i].first.second;
		a[i].second = i;
	}
	sort(a, a + n, ms);
	for (int i = 0; i < n; i++)
	{
		int k = a[i].first.first;
		while (se.find(k) != se.end())
			k++;
		res[a[i].second] = k;
		se.insert(k);
	}
	for (int i = 0; i < n; i++)
		printf("%d ", res[i]);
}

int main()
{
	prepare();
	solve();
	return 0;
}


#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cstring>
#include <string>
#include <map>
#include <queue>
#include <sstream>
#include <numeric>
#include <functional>
#include <set>
#include <cmath>
#include <stack>
#include <fstream>
#ifdef HOME_PC
#include <ctime>
#endif
using namespace std;

#pragma comment(linker,"/stack:16000000")
#pragma warning (disable : 4996)

#define ALL(v) v.begin(),v.end()
#define SZ(v) (int)v.size()
#define mset(A,x) memset((A),(x),sizeof(A))
#define FOR(i,start,N) for(int i=(start);i<(N);++i)
#define FORSZ(i,start,v) FOR(i,start,SZ(v))
#define REPSZ(i,v) FORSZ(i,0,v)
#define FORE(i,start,N) FOR(i,start,N+1)
#define make_unique(v) v.resize(unique(ALL(v))-v.begin())
#define debug(x) cout<<#x<<" = "<<x<<endl;
#define adebug(A,N) FOR(i,0,N) cout<<#A<<"["<<i<<"] = "<<A[i]<<endl;
#define adebug2d(a,n,m) FOR(i,0,n) { FOR(j,0,m) { cout<<a[i][j]<<" ";} cout<<endl;}
#define vdebug(v) REPSZ(i,v) cout<<#v<<"["<<i<<"] = "<<v[i]<<endl;
#define selfx(x,f,a) x = f(x,a)
#define sqr(x) ((x)*(x))

typedef pair<int,int> pii;
typedef long long i64;
typedef vector<int> VI; typedef vector< vector<int> > VVI;
typedef vector<string> VS;

const int inf = 1<<25;
const double eps = 1e-9;

int main(int argc, char* argv[])
{
#ifdef HOME_PC
	//freopen ("input.txt","r",stdin);
	//freopen ("in.txt","r",stdin);
	//freopen ("output.txt","w",stdout);
#endif

	int n;
	cin>>n;
	vector<pii> segs(n);
	FOR(i,0,n)
		cin>>segs[i].first >> segs[i].second;

	sort(ALL(segs));

	VI dates;
	dates.push_back(0);
	REPSZ(i,segs)
		dates.push_back(max(dates.back()+1,segs[i].first));

	FORSZ(i,1,dates)
		printf("%d ",dates[i]);

#ifdef HOME_PC
	cerr<<endl<<"Execution time = "<<clock()<<" ms"<<endl;
#endif
	return 0;
}


#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cstring>
#include <string>
#include <map>
#include <queue>
#include <sstream>
#include <numeric>
#include <functional>
#include <set>
#include <cmath>
#include <stack>
#include <fstream>
#ifdef HOME_PC
#include <ctime>
#endif
using namespace std;

#pragma comment(linker,"/stack:16000000")
#pragma warning (disable : 4996)

#define ALL(v) v.begin(),v.end()
#define SZ(v) (int)v.size()
#define mset(A,x) memset((A),(x),sizeof(A))
#define FOR(i,start,N) for(int i=(start);i<(N);++i)
#define FORSZ(i,start,v) FOR(i,start,SZ(v))
#define REPSZ(i,v) FORSZ(i,0,v)
#define FORE(i,start,N) FOR(i,start,N+1)
#define make_unique(v) v.resize(unique(ALL(v))-v.begin())
#define debug(x) cout<<#x<<" = "<<x<<endl;
#define adebug(A,N) FOR(i,0,N) cout<<#A<<"["<<i<<"] = "<<A[i]<<endl;
#define adebug2d(a,n,m) FOR(i,0,n) { FOR(j,0,m) { cout<<a[i][j]<<" ";} cout<<endl;}
#define vdebug(v) REPSZ(i,v) cout<<#v<<"["<<i<<"] = "<<v[i]<<endl;
#define selfx(x,f,a) x = f(x,a)
#define sqr(x) ((x)*(x))

typedef pair<int,int> pii;
typedef long long i64;
typedef vector<int> VI; typedef vector< vector<int> > VVI;
typedef vector<string> VS;

const int inf = 1<<25;
const double eps = 1e-9;

int main(int argc, char* argv[])
{
#ifdef HOME_PC
	//freopen ("input.txt","r",stdin);
	//freopen ("in.txt","r",stdin);
	//freopen ("output.txt","w",stdout);
#endif

	int n;
	cin>>n;
	vector< pair< pii,int > > segs(n);
	FOR(i,0,n)
		cin>>segs[i].first.first >> segs[i].first.second, segs[i].second = i;

	sort(ALL(segs));

	VI dates;
	VI ids;
	dates.push_back(0);
	REPSZ(i,segs)
		dates.push_back(max(dates.back()+1,segs[i].first.first)), ids.push_back(segs[i].second);

	VI ans(n);
	REPSZ(i,ids)
		ans[ids[i]] = dates[i+1];

	REPSZ(i,ans)
		printf("%d ",ans[i]);

#ifdef HOME_PC
	cerr<<endl<<"Execution time = "<<clock()<<" ms"<<endl;
#endif
	return 0;
}


#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cstring>
#include <string>
#include <map>
#include <queue>
#include <sstream>
#include <numeric>
#include <functional>
#include <set>
#include <cmath>
#include <stack>
#include <fstream>
#ifdef HOME_PC
#include <ctime>
#endif
using namespace std;

#pragma comment(linker,"/stack:16000000")
#pragma warning (disable : 4996)

#define ALL(v) v.begin(),v.end()
#define SZ(v) (int)v.size()
#define mset(A,x) memset((A),(x),sizeof(A))
#define FOR(i,start,N) for(int i=(start);i<(N);++i)
#define FORSZ(i,start,v) FOR(i,start,SZ(v))
#define REPSZ(i,v) FORSZ(i,0,v)
#define FORE(i,start,N) FOR(i,start,N+1)
#define make_unique(v) v.resize(unique(ALL(v))-v.begin())
#define debug(x) cout<<#x<<" = "<<x<<endl;
#define adebug(A,N) FOR(i,0,N) cout<<#A<<"["<<i<<"] = "<<A[i]<<endl;
#define adebug2d(a,n,m) FOR(i,0,n) { FOR(j,0,m) { cout<<a[i][j]<<" ";} cout<<endl;}
#define vdebug(v) REPSZ(i,v) cout<<#v<<"["<<i<<"] = "<<v[i]<<endl;
#define selfx(x,f,a) x = f(x,a)
#define sqr(x) ((x)*(x))

typedef pair<int,int> pii;
typedef long long i64;
typedef vector<int> VI; typedef vector< vector<int> > VVI;
typedef vector<string> VS;

const int inf = 1<<25;
const double eps = 1e-9;

int main(int argc, char* argv[])
{
#ifdef HOME_PC
	//freopen ("input.txt","r",stdin);
	//freopen ("in.txt","r",stdin);
	//freopen ("output.txt","w",stdout);
#endif

	int n;
	cin>>n;
	vector< pair< pii,int > > segs(n);
	FOR(i,0,n)
		cin>>segs[i].first.first >> segs[i].first.second, segs[i].second = i;

	VI dates;
	VI ids;
	dates.push_back(0);
	while(!segs.empty())
	{
		sort(ALL(segs));
		dates.push_back(max(dates.back()+1,segs[0].first.first)), ids.push_back(segs[0].second);
		reverse(ALL(segs));
		segs.pop_back();
		REPSZ(i,segs)
			segs[i].first.first = max(segs[i].first.first,dates.back()+1);
	}

	VI ans(n);
	REPSZ(i,ids)
		ans[ids[i]] = dates[i+1];

	REPSZ(i,ans)
		printf("%d ",ans[i]);

#ifdef HOME_PC
	cerr<<endl<<"Execution time = "<<clock()<<" ms"<<endl;
#endif
	return 0;
}


#include <iostream>

using namespace std;
#define N 102

struct even
{
	int i,l,r;
};

even a[N];

int cmp(const void *x,const void *y)
{
	even *u	=	(even*)x;
	even *v	=	(even*)y;
	if(u->l-v->l)
		return u->l-v->l;
	if(u->r-v->r)
		return u->r-v->r;
	return u->i - v->i;
}
void swap(int i,int j)
{
	int t;
	t	=	a[i].i;
	a[i].i	=	a[j].i;
	a[j].i	=	t;
	t	=	a[i].l;
	a[i].l	=	a[j].l;
	a[j].l	=	t;
	t	=	a[i].r;
	a[i].r	=	a[j].r;
	a[j].r	=	t;
}

void main()
{
	int i,j,k,l,n,m,b[N];
	cin >> n;
	for(i=1;i<=n;i++)
	{
		a[i].i	=	i;
		cin >> a[i].l >> a[i].r;
	}
	a[n+1].l	=	1e7 + 1;
	qsort(a+1,n,sizeof(even),cmp);
	i	=	1;
	while(i<=n)
	{
		j	=	i;
		while(a[j].l==a[i].l)
			j++;
		k	=	i;
		m	=	i + 1;
		l	=	a[i].l;
		while(k<j&&l<a[j].l)
		{
			if(l>a[k].r)
			{
				if(m<j)
				{
					swap(k,m);
					m++;
				}
				else
					break;
			}
			else
			{
				b[a[k].i]	=	l;
				l++;
				k++;
				m	=	k + 1;
			}
		}
		m	=	k;
		while(m<j)
		{
			a[m].l	=	a[j].l;
			m++;
		}
		qsort(a+k,n-k+1,sizeof(even),cmp);
		i	=	k;
	}
	for(i=1;i<=n;i++)
		cout << b[i] << " ";
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cstring>

using namespace std;

class Automaton {
  public:
    Automaton() {
        nodes_.resize(1);
        root_ = last_node_ = new Node(0);
        nodes_[0].push_back(root_);
    }

    void build(const string& S) {
        nodes_.resize(max(nodes_.size(), S.size() + 1));

        for (auto &c : S)
            extend(c - 'a');
    }

    vector<int> buildSpecial(const string &S) {
        nodes_.resize(max(nodes_.size(), S.size() + 1));

        vector<int> answer(S.size());
        for (int i = 0; i < int(S.size()); ++i) {
            extend(S[i] - 'a');
            answer[i] = last_node_->link->length + 1;
        }

        return answer;
    }

    void mark(const int &lower_bound, const int &upper_bound) {
        lower_bound_ = lower_bound;
        upper_bound_ = upper_bound;

        for (Node* k = last_node_; k; k = k->link)
            k->endings = 1;

        for (int i = nodes_.size() - 1; i >= 0; --i)
            for (auto &now : nodes_[i])
                for (int j = 0; j < 26; ++j)
                    if (now->next[j])
                        now->endings += now->next[j]->endings;

        // now we mark with lower bound and upper_bound
        root_->lower_bound = 1;
        for (int i = 1; i < int(nodes_.size()); ++i) // the 0 length string has 0 lower_bound and upper_bound
            for (auto &now : nodes_[i]) {
                if (now->endings >= lower_bound)
                    now->upper_bound = now->length; // we can be this long because we appear often enough
                else
                    now->upper_bound = now->link->upper_bound;  // we use our link information

                if (now->endings > upper_bound) // we appear too often
                    now->lower_bound = now->length + 1;         // at least this distance
                else
                    now->lower_bound = now->link->lower_bound;  // our link information
            }
    }

    pair< vector<int>, vector<int> > match(const string &S) {
        vector<int> lower_bound(S.size()), upper_bound(S.size());

        Node *k = root_;
        int length = 0;
        for (int i = 0; i < int(S.size()); ++i) {
            int edge = S[i] - 'a';
            while (k != root_ and not k->next[edge]) {
                k = k->link;
                length = k->length;
            }

            if (k->next[edge]) {
                k = k->next[edge];
                ++length;
            }

            lower_bound[i] = k->lower_bound;
            upper_bound[i] = min(k->upper_bound, length);

            if (lower_bound_ == 0)
                upper_bound[i] = i + 1;
        }

        return {lower_bound, upper_bound};
    }

  private:
    class Node {
      public:
        Node(const int &_length, Node * const _link = 0, Node **_next = 0):
                length(_length),
                link(_link),
                endings(0),
                lower_bound(0),
                upper_bound(0) {
            if (_next == 0)
                memset(next, 0, sizeof(next));
            else
                memcpy(next, _next, sizeof(next));
        }

        int length;
        Node *link, *next[26];
        int endings;
        int lower_bound, upper_bound;
    };

    void extend(const int &edge) {
        Node* now = new Node(last_node_->length + 1);
        nodes_[now->length].push_back(now);

        Node *k;
        for (k = last_node_; k and not k->next[edge]; k = k->link)
            k->next[edge] = now;

        last_node_ = now;

        if (k == 0) {
            now->link = root_;
            return;
        }

        Node *p = k->next[edge];
        if (k->length + 1 == p->length) {
            now->link = p;
            return;
        }

        Node *clone = new Node(k->length + 1, p->link, p->next);
        nodes_[clone->length].push_back(clone);
        now->link = p->link = clone;

        for (; k and k->next[edge] == p; k = k->link)
            k->next[edge] = p;
    }

    Node *root_, *last_node_;
    vector< vector<Node*> > nodes_;

    int lower_bound_, upper_bound_;
};

int main() {
    string S; cin >> S;

    int N; cin >> N;
    vector<Automaton> A(N);

    for (int i = 0; i < N; ++i) {
        string current; cin >> current;
        A[i].build(current);

        int lower_bound, upper_bound;
        cin >> lower_bound >> upper_bound;
        A[i].mark(lower_bound, upper_bound);
    }

    vector<int> lower_bound(S.size(), 1), upper_bound(S.size());
    for (int i = 0; i < int(S.size()); ++i)
        upper_bound[i] = i + 1;

    for (int i = 0; i < N; ++i) {
        vector<int> now_lower, now_upper;
        tie(now_lower, now_upper) = A[i].match(S);

        for (int j = 0; j < int(S.size()); ++j) {
            lower_bound[j] = max(lower_bound[j], now_lower[j]);
            upper_bound[j] = min(upper_bound[j], now_upper[j]);
        }
    }

    Automaton F;
    auto now_lower = F.buildSpecial(S);
    int answer = 0;
    for (int j = 0; j < int(S.size()); ++j) {
        lower_bound[j] = max(lower_bound[j], now_lower[j]);
        if (lower_bound[j] <= upper_bound[j])
            answer += upper_bound[j] - lower_bound[j] + 1;
    }

    cout << answer << "\n";
}


#include<algorithm>
#include<bitset>
#include<cassert>
#include<complex>
#include<cstdio>
#include<cstring>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<vector>
#define REP(i, n) for(int i=0;i<n;i++)
const int ALPH = 37;
const int INF = (int)1e9;
const int N = 600010;
struct Node
{
    Node* ch[ALPH];
    Node* f;
    int l, r, number;
    //l, r�Ǹ��׽ڵ�֮��ı�������ַ����
}node[2 * N + 10];
char s[N];
int belong[N];
int ret[N];
int L[10], R[10], k, len;
struct Tree
{
    int n, leaf, l, r;
    Node *root, *cur, *pool;
    void init(int n) {
        this->n = n;
        leaf = 0;
        pool = node;
    }
    Node* new_node(Node* p, char c, int _l, int _r, int _leaf) {
        Node *v = pool++;
        memset(v, 0, sizeof(Node));
        v->l = _l, v->r = _r, v->number = _leaf;
        if(p) p->ch[c] = v;
        return v;
    }
    void canonize() {
        while(l <= r) {
            Node *w = cur->ch[s[l - 1]];
            if(w->r - w->l <= r - l) {
                l += w->r - w->l + 1;
                cur = w;
            } else {
                break;
            }
        }
    }
    bool split(Node* &w) {
        w = cur;
        if(l <= r) {
            Node *x = cur->ch[s[l - 1]];
            if(s[x->l + r - l] == s[r]) {
                return true;
            }
            int k = x->l + r - l;
            Node* y = new_node(cur, s[x->l - 1], x->l, k, -1);
            y->ch[s[k]] = x; x->l = k + 1; w = y;
            return false;
        }
        return cur->ch[s[r]] != NULL;
    }
    void update() {
        Node* prev = root, *w;
        while(!split(w)) {
            new_node(w, s[r], r + 1, n, ++leaf);
            if(prev != root) {
                prev->f = w;
            }
            prev = w; cur = cur->f; canonize();
        }
        if(prev != root) {
            prev->f = cur;
        }
    }
    Node* create() {
        root = new_node(NULL, 0, 0, 0, -1);
        Node* top = new_node(NULL, 0, 0, -1, -2);
        REP(i, n) {
            top->ch[s[i]] = root;
        }
        root->f = top;
        cur = root; l = 1; r = 0;
        REP(i, n) {
            update(); r = i + 1; canonize();
        }
        return root;
    }
    long long ret;
    void solve() {
        ret = 0;
        int a[11];
        dfs(root, -1, a);
        printf("%I64d\n", ret);
    }
    void dfs(Node* u, int dep, int cnt[]) {
        bool leaf = true;
        int depth = dep + u->r - u->l + 1;
        int tmp[11];memset(tmp, 0, sizeof(tmp));
        REP(i, ALPH) {
            if(u->ch[i] != NULL) {
                leaf = false;
                dfs(u->ch[i], depth, tmp);
            }
        }
        if(leaf) {
            if(~belong[depth]) {
                tmp[belong[depth]]++;
            }
        }
        for(int i = 0; i <= 10; i++) {
            cnt[i] += tmp[i];
        }
        if(tmp[10]) {
            int c = 0;
            //for(int i = 0; i < k; i++) printf("%d " ,tmp[i]);puts("");
            for(int i = 0; i < k; i++) {
                if(tmp[i] >= L[i] && tmp[i] <= R[i]) {
                    c++;
                } else {
                    break;
                }
            }
            if(c == k) {
                if(u == root)  {
                    return ;
                }
                if(u->l > len) return ;
                if(!leaf && u->r > len) {
                    depth = depth - (u->r - len);
                }
                ret += depth - dep;
                if(leaf) {
                    ret--;
                }
            }
        }
    }
}T;
char t[N];
char word[10][N];
int main()
{
    //freopen("in.txt", "r", stdin);
    memset(belong, -1, sizeof(belong));
    int n = 0, mx = 26;
    scanf("%s", t);
    int l = strlen(t); len = l;
    //printf("len=%d\n", len);
    for(int i = 0; t[i]; i++) s[n++] = t[i]-'a';
    s[n++] = mx++;
    scanf("%d", &k);
    int len[10];
    for(int i = 0; i < k; i++) {
        scanf("%s%d%d", t, &L[i], &R[i]);
        strcpy(word[i], t);
        len[i] = strlen(t);
        for(int j = 0; t[j]; j++) {
            s[n++] = t[j] - 'a';
        }
        s[n++] = mx++;
    }
   // for(int i = 0; i < k; i++) printf("%d\n", len[i]);
    int pre = 1;
    for(int i = k - 1; i >= 0; i--) {
        for(int j = pre + 1; j <= pre + len[i]; j++) {
            belong[j] = i;
        }
        pre += len[i] + 1;
    }
    for(int i = pre + 1; i <= pre + l; i++) {
        belong[i] = 10;
    }
    T.init(n);
    T.create();
    T.solve();
    return 0;
}
/*
len=57
156 3 154
35 0 34
*/