#include<stdio.h>
#include<stdlib.h>
#include<algorithm>
#define INT long long int
using namespace std;

char in[100], out[100];
int A[100100];
int main(){
    int n, i, a, b, t, ans, cnt;
	for(int I = 1; I<=20; I++){
		sprintf(in,".%d.in",I);
        freopen(in,"w",stdout);
        n = I * 5000;
        printf("%d\n", n);
        for(i=0;i<86410;i++) A[i] = 0;
        for(i=0;i<n;i++){
            a = (rand()*1000+ rand())%86401;
            b = (rand()*1000+ rand())%86401;
            if(a>b){
                t = a;
                a = b;
                b = t;
            }
            printf("%d %d\n",a,b);
            A[a]++;
            A[b]--;
        }
        ans = cnt = 0;
        for(i=0;i<86410;i++){
            cnt += A[i];
            ans = max(ans, cnt);
        }
		sprintf(in,".%d.out",I);
        freopen(in,"w",stdout);
        printf("%d",ans);
	}
}
