#include <stdio.h>
#include <stdlib.h>
#define ll long long
#define rep(i,l,r)for(ll i=l;i<r;i++)

int c(const void*a,const void*b){
	ll ha=*(ll*)a/200;
	ll wa=*(ll*)a%200;
	ll hb=*(ll*)b/200;
	ll wb=*(ll*)b%200;
	
	if(ha*ha+wa*wa<hb*hb+wb*wb)return -1;
	if(ha*ha+wa*wa>hb*hb+wb*wb)return 1;
	if(ha<hb)return -1;
	if(ha>hb)return 1;
	return 0;
}

ll a[40010];
ll cnt;
int main(){
	rep(i,1,150)rep(j,i+1,150)a[cnt++]=i*200+j;
	qsort(a,cnt,sizeof(ll),c);
//	rep(i,0,10)printf("%lld %lld\n",a[i]/200,a[i]%200);

	ll h,w;
	while(scanf("%lld%lld",&h,&w),h){
		ll d=h*200+w;
		ll l=0;//ng
		ll r=cnt;//ok
		while(r-l>1){
			ll m=(l+r)/2;
			if(c(&a[m],&d)==1)r=m;
			else l=m;
		}
		printf("%lld %lld\n",a[r]/200,a[r]%200);
	}
}
