#include<stdio.h>
int main(){
  int w,h,mi,mj,i,j,s;
  while(scanf("%d %d",&h,&w),w||h){
    int l=(w*w+h*h)*150*150+h,min=150*150*150*150+150;
    for(i=1;i<150;i++){
      for(j=i+1;j<150;j++){
	s=(i*i+j*j)*150*150+i;
	if(l<s&&s<min){
	  min=s;
	  mi=i;
	  mj=j;
	}
      }
    }
    printf("%d %d\n",mi,mj);
  }
  return 0;
}