#include <stdio.h>
#include <algorithm>
using namespace std;
int N, cnt, start;
struct data{
int x, y;
bool operator<(const data &r) const {
return x != r.x ? x < r.x : y < r.y;
}
}a[2000000], b[500000];
void setting(){
int i, sw = 0;
for(i = start; i < N + start; i++){
if(a[i].x == a[i + 1].x && a[i].y * a[i + 1].y < 0){
if(!sw) b[cnt].x = a[i].x;
else b[cnt++].y = a[i].x;
sw = 1 - sw;
}
}
for(i = 0; i < cnt; i++){
if(b[i].x > b[i].y) swap(b[i].x, b[i].y);
}
sort(b, b + cnt);
}
void output(){
int ans1 = 1, ans2 = 1, flag = b[0].y;
for(int i = 1; i < cnt; i++){
if(b[i].x > flag){
ans1++;
flag = b[i].y;
}
if(b[i - 1].y < b[i].x) ans2++;
}
printf("%d %d", ans1, ans2);
}
int main()
{
scanf("%d", &N);
for(int i = 0; i < N; i++){
scanf("%d %d", &a[i].x, &a[i].y);
a[i + N] = a[i];
if(a[i] < a[start]) start = i;
}
setting();
output();
return 0;
}
ÀÌ°Ô ¼±»ý´ÔÀÌ ¾²½Å ÄÚµå¶û ¶È°°Àºµ¥... ¿Ö 38Á¡ÀÌ ³ª¿À´Â °ÅÁÒ?