#include<stdio.h>
int main(void){
  int i, j, h, w, squ, ans[3]={1}, sum;

  scanf("%d%d", &h, &w);
  while(h!=0 && w!=0){
    squ=h*h+w*w;
    ans[2]=150*150;
    for(i=1;i<151;i++){
      for(j=1;j<151;j++){
        sum=i*i+j*j;
        if(i>=j){
          continue;
        }
        if(sum>squ){
          if(ans[2]>sum){
            ans[2]=sum;
            ans[0]=i;
            ans[1]=j;
          }
          if(ans[2]==sum && ans[0]>i){
            ans[2]=sum;
            ans[0]=i;
            ans[1]=j;
          }
        }
        if(sum==squ && i>h){
          ans[2]=sum;
          ans[0]=i;
          ans[1]=j;
        }
      }
    }

    printf("%d %d\n", ans[0], ans[1]);
    scanf("%d%d", &h, &w);
  }

  return 0;
}