#include<stdio.h>
#include<math.h>
#define inf 100000000
int min;
int h, w, len;
int x, y;
int length(int x, int y){
    return x*x + y*y;
}
void judge(void){
    int i, j;
    x=0; y=0; min=inf;
    len=length(h,w);
    for(int i=1;i<151;i++){
        for(int j=i+1;j<151;j++){
            if(len==length(i,j) && i>h){
                printf("%d %d\n",i,j);
                return;
            }
            else if(len < length(i,j) && length(i,j) < min){
                min = length(i,j);
                x=i; y=j;
            }
            else if(min < length(i,j)){
                break;
            }
        }
        if(min < length(i,1)) break;
    }
    printf("%d %d\n",x,y);
}
int main(void){
    while(1){
        scanf("%d%d",&h,&w);
        if(h==0 && w==0) break;
        judge();
    }
    return 0;
}

