
#include<stdio.h>

#define MAX 150

int length(int h, int w) {return h * h + w * w;}

int lessOrEqual(int h1, int w1, int h2, int w2) {
    int l1 = length(h1, w1);
    int l2 = length(h2, w2);
    if(l1 != l2) return l1 < l2;
    return h1 <= h2;
}

int main(void) {
    int h, w;
    int answerH, answerW;
    int i, j;
    while(scanf("%d %d", &h, &w), h | w) {
        answerH = answerW = MAX;
        for(i = 1; i <= MAX; i++) {
            for(j = i + 1; j <= MAX; j++) {
                if(lessOrEqual(i, j, h, w)) continue;
                if(lessOrEqual(answerH, answerW, i, j)) continue;
                answerH = i;
                answerW = j;
            }
        }
        printf("%d %d\n", answerH, answerW);
    }
    return 0;
}