#include<bits/stdc++.h>
#define LL long long
using namespace std;
const int N=2e7+7;
const int CC=1e7;
LL a[N];
int n,ans;
int main()
{
freopen("daoshu.in","r",stdin);
freopen("daoshu.out","w",stdout);
scanf("%d",&n);
for (int i=1;i<=n;i++)
{
LL x,y;
scanf("%lld%lld",&x,&y);
y=y+CC;
a[y]+=x;
}
for (int i=1;i<=N-1;i++) if (a[i]) ans++;
printf("%d\n",ans);
for (int i=N-1;i>=1;i--)
if (a[i])
{
printf("%d ",a[i]*(i-CC));
printf("%d\n",i-CC-1);
}
return 0;
}