#include <stdio.h>

int main(){
    int i,j,k,h,w,min,minh,minw;

    for(i=0;i<100;i++){
        scanf("%d %d", &h, &w);
        if(h==0&&w==0) break;
        min =150*150 +150 * 150;
        minh = 150;
        minw = 150;
        for(j=1;j<=150;j++){
            for(k=j+1;k<=150;k++){
                if((j*j+k*k)>(h*h+w*w)&&(j*j+k*k)<min){
                    min = j*j+k*k;
                    minh = j;
                    minw = k;
                }
                if(((j*j+k*k)==(h*h+w*w)&&h<j &&min != h*h+w*w)){
                    min = j*j+k*k;
                    minh = j;
                    minw = k;
                }
            }
        }
        printf("%d %d\n",minh,minw);
    }
    return 0;
}