#include <stdio.h>
#include <math.h>

int main(void)
{
    int H, W;
    int h, w;
    int dia;
    int min_h, min_w, min_dia;
    
    while (1){
        scanf("%d%d", &H, &W);
        if (H == 0 && W == 0){
            break;
        }
        
        dia = H * H + W * W;
        
        min_h = min_w = 150;
        min_dia = min_h * min_h + min_w * min_w;
        
        h = 1;
        w = sqrt(dia);
        
        while (h < w){
            while ((dia > (h * h + w * w)) ||
                   (dia == (h * h + w * w)) && (h < H)){
                w++;
            }

//printf("<%d %d>\n", h, w);

            while (dia < (h * h + w * w) ||
                (dia == (h * h + w * w)) && h > H){
                w--;
            }
            w++;
            if (h >= w){
                w = h + 1;
            }

//printf("[%d %d]\n", h, w);

            
            if (min_dia > (h * h + w * w)){
                min_h = h;
                min_w = w;
                min_dia = min_h * min_h + min_w * min_w;
            }
            else if (min_dia == (h * h + w * w) && (h < min_h)){
                min_h = h;
                min_w = w;
                min_dia = min_h * min_h + min_w * min_w;
            }
//printf("<<%d %d>>\n", min_h, min_w);
            h++;
        }
        printf("%d %d\n", min_h, min_w);
    }
    return (0);
}