#include<stdio.h>
int main()
{
int i,j,k,a,b;
for(a=3; a<=1500; a++){
for(i=1,j=0; i<a; i++){
if(a%i==0)
j+=i;
}
for(b=2; b<a; b++){
for(i=1,k=0; i<b; i++){
if(b%i==0)
k+=i;
}
if(j==b && k==a){
for(i=2; i<a; i++){
if(a%i==0)
}
for(i=2; i<b; i++){
if(b%i==0)
}
}
}
}
for(i=2; i<b; i++){
if(b%i==0)
}
}
I2luY2x1ZGU8c3RkaW8uaD4KCmludCBtYWluKCkKewogICAgaW50IGksaixrLGEsYjsKCiAgICBmb3IoYT0zOyBhPD0xNTAwOyBhKyspewogICAgICAgIGZvcihpPTEsaj0wOyBpPGE7IGkrKyl7CiAgICAgICAgICAgIGlmKGElaT09MCkKICAgICAgICAgICAgICAgIGorPWk7CiAgICAgICAgfQoKICAgICAgICBmb3IoYj0yOyBiPGE7IGIrKyl7CiAgICAgICAgICAgIGZvcihpPTEsaz0wOyBpPGI7IGkrKyl7CiAgICAgICAgICAgICAgICBpZihiJWk9PTApCiAgICAgICAgICAgICAgICAgICAgays9aTsKICAgICAgICAgICAgfQoKICAgICAgICAgICAgaWYoaj09YiAmJiBrPT1hKXsKICAgICAgICAgICAgICAgIHByaW50ZigiJWRcdCVkXG4iLGEsYik7CiAgICAgICAgICAgICAgICBmb3IoaT0yOyBpPGE7IGkrKyl7CiAgICAgICAgICAgICAgICAgICAgaWYoYSVpPT0wKQogICAgICAgICAgICAgICAgICAgICAgICBwcmludGYoIiVkICIsaSk7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBwcmludGYoIlxuIik7CiAgICAgICAgICAgICAgICBmb3IoaT0yOyBpPGI7IGkrKyl7CiAgICAgICAgICAgICAgICAgICAgaWYoYiVpPT0wKQogICAgICAgICAgICAgICAgICAgICAgICBwcmludGYoIiVkICIsaSk7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBwcmludGYoIlxuIik7CiAgICAgICAgICAgIH0KICAgICAgICB9CiAgICB9CgogICAgcHJpbnRmKCIlZFxuIixqKTsKICAgIHByaW50ZigiJWRcbiIsYik7CiAgICBmb3IoaT0yOyBpPGI7IGkrKyl7CiAgICAgICAgaWYoYiVpPT0wKQogICAgICAgICAgICBwcmludGYoIiVkICIsaSk7CiAgICB9CiAgICBwcmludGYoIlxuXG4lZFxuIixrKTsKfQo=