#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include<stdio.h>
#define Pow(a,b) (a*a)+(b*b)
int main() {
	int h, w, hMin, wMin,min,hTmp;
	int i, j;
	while (1) {
		scanf("%d%d", &h, &w);
		if (!(h + w))break;
		min = 150*150;
		for (i = 150; i > 0; --i) {
			for (j = 150; j > 0; --j) {
				if ((min>=Pow(i,j))&&(Pow(h,w)<Pow(i,j))&&j>i) {
					min = (i*i) + (j*j); hMin = i; wMin = j;
				}
			}
		}
		printf("%d %d\n", hMin, wMin);
	}

	return 0;
}