#include <stdio.h>


void solve(int h, int w){
	int x,y=1;
	int tr=h*h+w*w;
	int min_x,min_y,min_tr=100000;
	while(1){
		x=y+1;
		if(tr<x*x+y*y){
			if(min_tr>x*x+y*y){
				min_tr=x*x+y*y;
				min_x=x;
				min_y=y;
			}
			break;
		}
		if(tr==x*x+y*y){
			if(y>h){
				printf("%d %d\n",y,x);
				return;
			}
		}
		while(1){
			if(tr==x*x+y*y){
				if(y>h){
					printf("%d %d\n",y,x);
					return;
				}
			}
			if(tr<x*x+y*y){
				if(min_tr>x*x+y*y){
					min_tr=x*x+y*y;
					min_x=x;
					min_y=y;
				}
				break;
			}
			x++;
		}
		y++;
	}
	printf("%d %d\n",min_y,min_x);
	return;
}

int main(void){
	int h,w;
	while(scanf("%d %d",&h,&w),h||w){
		solve(h,w);
	}
	return 0;
}