#include <stdio.h>

int main(void) {
    int h, w;

    while (scanf("%d%d", &h, &w), h != 0) {
        int x = h * h + w * w;
        int bigh = h + 1;
        int bigw = w + 1;
        int h2, w2;
        for (h2 = 1; h2 < 150; h2++) {
            for (w2 = 1; w2 < 150; w2++) {
                if (h2 >= w2)
                    continue;
                if ((h2 * h2 + w2 * w2 > x &&
                     h2 * h2 + w2 * w2 < bigh * bigh + bigw * bigw)
                    || (h2 * h2 + w2 * w2 == bigh * bigh + bigw * bigw && h2 < \
bigh)
                    || (h2 * h2 + w2 * w2 == x && h2 > h)) {
                    bigh = h2;
                    bigw = w2;
                }
            }
        }
        printf("%d %d\n", bigh, bigw);
    }
    return 0;
}