#include "bits/stdc++.h"
using namespace std;
#define ll long long int
int main() {
vector<ll>start;
vector<ll>last;
for(int i=1;i<=9;i++)
{
int u,v; cin>>u>>v;
start.push_back(u);
last.push_back(v);
}
sort(start.begin(),start.end());
sort(last.begin(),last.end());
int p = 5;
ll d=lower_bound(start.begin(),start.end(),p+1)-start.begin();
ll u=upper_bound(last.begin(),last.end(),p-1)-last.begin();
u=last.size()-u;
cout<<d<<" "<<u<<endl;
ll get=min(d,u);
cout<<"number of segments which cross point"<<p<<" is "<< get<<endl;
return 0;
}
I2luY2x1ZGUgImJpdHMvc3RkYysrLmgiCnVzaW5nIG5hbWVzcGFjZSBzdGQ7CiNkZWZpbmUgbGwgbG9uZyBsb25nIGludAoKCmludCBtYWluKCkgewoJdmVjdG9yPGxsPnN0YXJ0OwoJdmVjdG9yPGxsPmxhc3Q7CgkKICAgZm9yKGludCBpPTE7aTw9OTtpKyspCiAgIHsKICAgCSAgIGludCB1LHY7IGNpbj4+dT4+djsKICAgICAgIHN0YXJ0LnB1c2hfYmFjayh1KTsKICAgICAgIGxhc3QucHVzaF9iYWNrKHYpOwogICB9CiAgIHNvcnQoc3RhcnQuYmVnaW4oKSxzdGFydC5lbmQoKSk7CiAgIHNvcnQobGFzdC5iZWdpbigpLGxhc3QuZW5kKCkpOwogICAKICAgIGludCBwID0gNTsKICAgIGxsIGQ9bG93ZXJfYm91bmQoc3RhcnQuYmVnaW4oKSxzdGFydC5lbmQoKSxwKzEpLXN0YXJ0LmJlZ2luKCk7CiAgICBsbCB1PXVwcGVyX2JvdW5kKGxhc3QuYmVnaW4oKSxsYXN0LmVuZCgpLHAtMSktbGFzdC5iZWdpbigpOwogICAgdT1sYXN0LnNpemUoKS11OwogICAgY291dDw8ZDw8IiAiPDx1PDxlbmRsOwogICAgbGwgZ2V0PW1pbihkLHUpOwogICAgY291dDw8Im51bWJlciBvZiBzZWdtZW50cyB3aGljaCBjcm9zcyBwb2ludCI8PHA8PCIgaXMgIjw8IGdldDw8ZW5kbDsKCXJldHVybiAwOwp9