#include <stdio.h>

int main(void)
{
  int W,H,L,l[150][150],i,j,w,h,k,A;
  
  while(1){
    W = H = L = w = h = 0;
    scanf("%d %d", &H,&W);
    if(H == 0)
      break;
    L = W*W + H*H;
    A = 44701;
    /*iは高さ。jは幅*/
    for(i = 1;i < 150;i++){
      for(j = i+1;j <= 150;j++){
	  l[i][j]=i*i+j*j;
	  /* printf("%d,%d %d\n", i,j,l[i][j]);*/
      }
    }
    /*  printf("\n\n");*/
    for(i = 1;i < 150;i++){
      for(j = i+1;j <= 150;j++){
	for(k = 0;k < 10000;k++){
	  if(l[i][j] == L+k && A > l[i][j]){
	    if(i != H && j == W || i == H && j != W || i != H && j != W){
	      h=i;
	      w=j;
	      A=L+k;
	    }
	    /* printf("%d %d %d %d\n", i,j,l[i][j],L+k);*/
	  }
	}
      }
    }
    printf("%d %d\n", h,w);  
  }
  return 0;
}