#include <stdio.h>

int main(){
    int h, w;
    int i,j;
    int min_i,min_j,m_h;
    long int taikaku,min;

    while(1){
        min = 0;
        

        scanf("%d %d",&h,&w);
        if(h == 0 && w == 0){
            break;
        }

        taikaku = h*h + w*w;
        min_i = h;
        min_j = 0;
        m_h = 150;

        min = 150*150 + 150*150;
        for(i = 1; i <= 150 ; i++){
            for(j = i + 1; j <= 150 ; j++){
                if(h == i && w == j)
                    break;
                
                       
                if( (i*i + j*j) > taikaku && min >= (i*i + j*j) ){
                    if(min == (i*i + j*j)){
                        if(i < min_i){
                         min_i = i;
                         min_j = j;
                        }
                        
                    }else{
                        min = i*i+j*j;
                        min_i = i;
                        min_j = j;

                 }
               }else if((i*i + j*j) == taikaku){
                   if(i > h && i <= m_h){
                    m_h = i;
                    min_i = i;
                    min_j = j;
                    min = i*i+j*j;
                   }
               }
               
            }
        }
        printf("%d %d\n",min_i,min_j);



    }
    return 0;

}
