#include <stdio.h>

int sortplus(int x[],int y[],int l){
	int h,i,j,k;
	for(i=1;i<=l;i++){
		for(j=l;j>=i+1;j--){
			if(x[j-1]>x[j]){
				k=x[j];
				h=y[j];
				x[j]=x[j-1];
				y[j]=y[j-1];
				x[j-1]=k;
				y[j-1]=h;
			}
		}
	}
	return 0;
}

int main(void) {
	int d[16384],xy[16384],h,w,s,k,i,no=0;
	for(h = 1;h <= 150;h++){
		for(w = h+1;w <= 150;w++){
			no++;
			d[no] = h*h+w*w;
			xy[no] = 1000*h+w;
		}
	}
	sortplus(d,xy,no);
	while(scanf("%d%d",&h,&w) , h != 0){
		s = h*h+w*w;
		k = 1000*h+w;
		for(i = 1;i <= no;i++){
			if(xy[i] == k){
				printf("%d %d\n",xy[i+1] / 1000,xy[i+1] % 1000);
				break;
			}
		}
	}
	return 0;
}