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

#define INF 1000000000

int max(int a, int b)
{
    if (a > b)
    {
        return a;
    }
    return b;
}

int min(int a, int b)
{
    if (a > b)
    {
        return b;
    }
    return a;
}

int main(void)
{
    int W, H;
    while (1)
    {
        scanf("%d %d", &H, &W);
        if (H == 0 && W == 0)
        {
            break;
        }
        int status = 0;
        int def = H * H + W * W;
        int distance;
        int ans = INF; // defaultより大きい最小の横長整長方形
        int w, h;
        int ans_h = INF, ans_w = INF;
        for (h = 1; h <= 149; h++)
        {
            if (status != 0)
            {
                break;
            }
            for (w = h + 1; w <= 150; w++)
            {
                if (status != 0)
                {
                    break;
                }
                if (w == W && h == H)
                {
                    continue;
                }
                distance = w * w + h * h;
                if (def == distance)
                {
                    if (h >= H)
                    {
                        ans = def;
                        ans_h = h;
                        ans_w = w;
                        status = 1;
                    }
                }
                else if (def < distance)
                {
                    if (ans > distance) // 直前より対角線の長さが短いとき
                    {
                        ans = distance;
                        ans_h = h;
                        ans_w = w;
                    }
                    else if (ans == distance) // 対角線の長さが同じならば，高さの低いほうが小さい
                    {
                        if (ans_h > h)
                        {
                            ans_h = h;
                            ans_w = w;
                        }
                    }
                }
            }
        }
        printf("%d %d\n", ans_h, ans_w);
    }
    return 0;
}
