#include<bits/stdc++.h>
using namespace std;
int n,m,cnt,fa[100015];
int find(int x){
	return x==fa[x]?x:fa[x]=find(fa[x]);
}
int main()
{
	freopen("5.in","w",stdout);
	srand(time(0));
	int n=30000;
	cout<<n<<endl;
	for(int i=1;i<=n;i++)fa[i]=i;
	while(cnt<n-1){
		int x=rand()*rand(),y=rand()*rand();
		x=x%n+1;
		y=y%n+1;
		int x1=find(x),y1=find(y);
		if(x1!=y1) fa[x1]=y1,cnt++,cout<<x<<" "<<y<<endl;
	}
	return 0;
}