#include <stdio.h>

void rectangle(int length, int height);

int main(){
	int height, width;
	int length;

	while(1){
		scanf("%d", &height);
		scanf("%d", &width);
		if(height==0 && width==0) break;
		length = height*height + width*width;
		rectangle(length, height);
	}

	return 0;
}

void rectangle(int length, int height){
	int i = height + 1;
	int j = 0;
	int len;

	while(length>2*i*i){
		do{
			j++;
			len = i*i + (i+j)*(i+j);
		} while (length>len);
		if(length==len){
			printf("%d %d\n", i, i+j);
			return;
		}
		i++;
		j = 0;
	}
	rectangle(length+1, 0);
}