#include <stdio.h>

int main(void)
{
    while(1){
        int i, j;
        int h, w;
        int diagonal;
        int lm_h, lm_w;
        int lm_diagonal;

        scanf("%d %d", &h, &w);

        if(h == 0 && w == 0)
            break;

        diagonal = h * h + w * w;
        lm_h = lm_w = 101;
        lm_diagonal = lm_h * lm_h + lm_w * lm_w;

        for(i = 1; i <= 150; i++){//height
            for(j = i + 1; j <= 150; j++){//width
                int temp_diagonal = i * i + j * j;
                if((temp_diagonal > diagonal) || (temp_diagonal == diagonal && i > h)){//larger
                    if((temp_diagonal < lm_diagonal) || (temp_diagonal == lm_diagonal && i < lm_h)){
                        lm_h = i;
                        lm_w = j;
                        lm_diagonal = temp_diagonal;
                    }
                }
            }
        }

        printf("%d %d\n", lm_h, lm_w);
    }

    return 0;
}