#include <stdio.h>
int function(int n)
{ int i, sum; sum = 1; for (i = 2;i<=n/2;i++) if(n%i==0) sum =sum+i; return sum;
}
void main()
{ int a, b, c; for(a = 6;a<=5000;a++){ b = function(a); c = function(b); if(c==a && a < b) printf("%5d%5d\n",a, b); }
}