#include <stdio.h>

int main(void) {
    int h, w, i, j, min, large, minh, minw;
    scanf("%d %d",&h, &w);
    while(h) {
        large = h * h + w * w;
        min = large + 100;
        minh = 150;
        minw = 150;
        for(i = 1; i < 150; i++ ) {
            for(j = i + 1; j < 150; j++ ) {
                if(i == h && j == w) {
                    continue;
                }
                if(large <= i*i+j*j ) {
                    if(large == i*i+j*j && i < h) {
                        continue;
                    }
                    if(min > i*i+j*j) {
                        min = i*i+j*j;
                        minh = i;
                        minw = j;
                    } else if(minh > i ) {
                        minh = i;
                        minw = j;
                        
                    }
                }
            }
        }
        printf("%d %d\n",minh, minw);
        scanf("%d %d",&h,&w);
    }
    return 0;
}
                