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

#define RECT(h, w) ((h) << 8 | (w))
#define HEIGHT(rect) ((rect) >> 8)
#define WIDTH(rect) ((rect) & 0xFF)
#define MAX 150

int rects[MAX * MAX];

int comp_rect(const void* a, const void* b)
{
    int t = HEIGHT(*(int*)a) * HEIGHT(*(int*)a) - HEIGHT(*(int*)b) * HEIGHT(*(int*)b)
            + WIDTH(*(int*)a) * WIDTH(*(int*)a) - WIDTH(*(int*)b) * WIDTH(*(int*)b);

    return t ? t : HEIGHT(*(int*)a) - HEIGHT(*(int*)b);
}

int main(void)
{
    int h, w, i, rect;

    for(i = 0, w = 2; w < MAX; w++)
        for(h = 1; h < w; h++)
            rects[i++] = RECT(h, w);

    qsort(rects, i, sizeof(int), comp_rect);

    while(scanf("%d%d", &h, &w), w + h)
    {
        rect = RECT(h, w), i = 0;

        while(comp_rect(&rects[i], &rect) <= 0)
            i++;

        printf("%d %d\n", HEIGHT(rects[i]), WIDTH(rects[i]));
    }

    return 0;
}