#include <stdio.h>
#include <math.h>

double memo[150][150];

int main(void){
  int i,j,h,w;
  int min,now,nh,nw,nnh,nnw;
  while(1){
    scanf("%d%d",&h,&w);
    if(h+w==0)break;
    //if(h<w-1)printf("%d %d\n",h+1,w);
    //else{
    now = h*h+w*w;
    min = now*1500;
    nh = 150;
    nw =150;
    nnh = 150;
    nnw = 150;
    for(i=1;i<=150;i++){
      for(j=i+1;j<=150;j++){
	//if(i*i+j*j==4069)printf("%d %d %d %d %d\n",now,min,i*i+j*j,i,j);
	if(now==i*i+j*j&&h<i&&nnh>i){
	  //printf("a%d %d\n",i,j);
	  nnw = j;
	  nnh = i;
	}
	if(now<i*i+j*j&&min>=i*i+j*j){
	  //printf("%d %d %d %d %d\n",now,min,i*i+j*j,i,j);
	  if(min==i*i+j*j&&nh>i){
	    nh = i;
	    nw = j;
	  }
	  else if(min>i*i+j*j){
	    nh = i;
	    nw = j;
	    min = i*i+j*j;
	  }
	}
      }
    }
    if(nnh != 150){
      nh = nnh;
      nw = nnw;
    }
    printf("%d %d\n",nh,nw);
  }
  return 0;
}
