// Aizu 1186: Integral Rectangles
// 2017.9.13 bal4u@uu

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

#define MAX 11500
typedef struct { int h, w, d2; } T;
T tbl[MAX+5]; int size;

int cmp(T *a, T *b) { if (a->d2 - b->d2) return (a->d2 - b->d2); return a->h - b->h; }

int bsrch(int a)
{
	int left = 0, right = size - 1, mid;
    while (left < right) {
		mid = (left + right) >> 1;
        if (tbl[mid].d2 < a) left = mid + 1; else right = mid;
    }
    if (tbl[left].d2 < a) left++;
	return left;
}

int main()
{
	int w, h, n, d2;
	
	for (size = 0, h = 1; h <= 150; h++) for (w = h+1; w <= 150; w++)
		tbl[size].h = h, tbl[size].w = w, tbl[size].d2 = h*h+w*w, size++;
	qsort(tbl, size, sizeof(T), cmp);
	while (scanf("%d%d", &h, &w) && h) {
		d2 = h*h+w*w, n = bsrch(d2);
		while (tbl[n].d2 == d2 && tbl[n].h <= h) n++;
		printf("%d %d\n", tbl[n].h, tbl[n].w);
	}
	return 0;
}