#include <stdio.h>

int main(int argc, const char * argv[]) {
    
    long h,w,d;
    long x,y,xy;
    long hikaku[3] = {999};
    int xx,yy;
    while (1) {
        
        hikaku[0] = 999;
        hikaku[1] = 999;
        hikaku[2] = 8999999;
            h=xx;
            w=yy;
        scanf("%ld %ld",&h,&w);
        if (h==0 && w==0) {
            break;
        }
        
        d=h*h+w*w;
        
        for (y=1; y<=150; y++) { //????????´???
            for (x=y+1;x<=150; x++) {
                xy = x*x + y*y;
                
                if (h==y && w==x) {
//                    printf("h==y w==x\n");
                    continue;
                }

                if (d < xy) {
//                    printf("in");
                    if (hikaku[2] > xy) {
                        hikaku[0] = x;
                        hikaku[1] = y;
                        hikaku[2] = xy;
                    }else if (hikaku[2] == xy) {
                        if (hikaku[1] > y) {
                            hikaku[0] = x;
                            hikaku[1] = y;
                            hikaku[2] = xy;
                        }
                    }
                }
            }
        }
    printf("%ld %ld\n",hikaku[1],hikaku[0]);
            
    }
    return 0;
}