#include <stdio.h>

int a[150 * 150][2];

int comp(int h1, int w1, int h2, int w2){
	int sum1,sum2;
	sum1 = h1 * h1 + w1 * w1;
	sum2 = h2 * h2 + w2 * w2;
	
	if(sum1 == sum2 && h1 < h2){ return 1; } 
	if(sum1 < sum2){ return 1; }
	return 0;
}

int main(){

int h, w;
int i, j;
int H = 150, W = 150;

while(1){
	scanf("%d%d",&h , &w);
	if(h == 0 && w == 0) break;
	H = 150, W = 150;

	for (i = 1; i <= 150; i++){
		for (j = 1; j <= 150; j++){
			if(!(i < j)) continue;
			if(comp(h, w, i , j)){
				if(comp(i, j , H, W)){
					H = i;
					W = j;
				}
			}
		}
	}
	printf("%d %d", H , W);
	printf("\n");
}
	return 0;
}