#include<iostream> //求中位数
#include<algorithm>
#include<stdio.h>
using namespace std;
struct node
{
int p,a;
bool operator<(const node& o)const
{
if(p==o.p)
return a<o.a;
else
return p<o.p;
}
}ans[1000000];
int main()
{
int n,i,mid;
while(cin>>n)
{
for(i=0;i<n;++i)
cin>>ans[i].p>>ans[i].a;
sort(ans,ans+n);
int len=0;
for(i=0;i<n;++i)
{
if(i>0&&ans[i].p>ans[i-1].p)
{
mid=(i-len+i-1)/2;
if(len%2==1)
printf("%d %d\n",ans[i-1].p,ans[mid].a);
else
printf("%d %d\n",ans[i-1].p,(ans[mid].a+ans[mid+1].a)/2);
len=1;
}
else
len++;
}
mid=(n-len+n-1)/2;
if(len%2==1)
printf("%d %d\n",ans[n-1].p,ans[mid].a);
else
printf("%d %d\n",ans[n-1].p,(ans[mid].a+ans[mid+1].a)/2);
}
return 0;
}
#include<algorithm>
#include<stdio.h>
using namespace std;
struct node
{
int p,a;
bool operator<(const node& o)const
{
if(p==o.p)
return a<o.a;
else
return p<o.p;
}
}ans[1000000];
int main()
{
int n,i,mid;
while(cin>>n)
{
for(i=0;i<n;++i)
cin>>ans[i].p>>ans[i].a;
sort(ans,ans+n);
int len=0;
for(i=0;i<n;++i)
{
if(i>0&&ans[i].p>ans[i-1].p)
{
mid=(i-len+i-1)/2;
if(len%2==1)
printf("%d %d\n",ans[i-1].p,ans[mid].a);
else
printf("%d %d\n",ans[i-1].p,(ans[mid].a+ans[mid+1].a)/2);
len=1;
}
else
len++;
}
mid=(n-len+n-1)/2;
if(len%2==1)
printf("%d %d\n",ans[n-1].p,ans[mid].a);
else
printf("%d %d\n",ans[n-1].p,(ans[mid].a+ans[mid+1].a)/2);
}
return 0;
}