#include <stdio.h>

int main(){
  int h;
  int w;
  int i;
  int j;
  int ans_h;
  int ans_w;
  int naname_1;//???????????£??\??????????????°
  int naname_2;
  int naname_3;

  while(1){
    scanf("%d %d",&h,&w);
    if(h==0 && w==0) break;

    ans_h=160;
    ans_w=160;
    
    naname_1 =(h*h) + (w*w);
    naname_3=(ans_h*ans_h)+(ans_w*ans_w);

  for(i=1;i<=150;i++){
    for(j=1;j<=150;j++){
      naname_2 =(j*j)+(i*i);
      if(j>i){
	if(naname_1 < naname_2 || (naname_1==naname_2&&h<i)){
	  if(naname_2<naname_3 || (naname_2==naname_3&&i<ans_h)){
	    ans_h=i;
	    ans_w=j;
	    naname_3=(ans_h*ans_h)+(ans_w*ans_w);
	  }
	}

      }
      
    }
  }
  printf("%d %d\n",ans_h,ans_w);
  }
  return 0;
}