#include <stdio.h>

int main(){

  int s,h,w,i,j,min=45000,a,b;
  int s2[151][151]={{}};


  for(;;){
    scanf("%d %d",&h,&w);
    if(h==0&&w==0){
      break;
    }
    s=h*h+w*w;

    for(i=1;i<=150;i++){
      for(j=i+1;j<=150;j++){
	s2[i][j]=i*i+j*j;
	if(s2[i][j]>s){
	  if(min>s2[i][j]){
	    min=s2[i][j];
	    a=i;
	    b=j;
	  }
	}
	else if(s2[i][j]==s){
	  
	  if(i>h){
	    a=i;
	    b=j;
	    printf("%d %d\n",a,b);
	    break;
	  }
	}
      }
      if(s2[i][j]==s&&i>h){
	break;
      }
    }
    if(s2[i][j]>s)printf("%d %d\n",a,b);
    min=45000;
    for(i=1;i<=150;i++){
      for(j=1;j<=150;j++){
	s2[i][j]=0;
      }
    }
  } 
  
  return 0;
}
	
    