#include <stdio.h>

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