/*
  AOJ 1186
  Title:Integral Rectangles
  @kankichi573
*/
#include <stdio.h>

int w,h;
char square_sum_table[20001];
char square_table[20001];

void make_square_sum()
{
  int i,j;
  for(i=0;i<10000;i++)
    square_sum_table[i]=0;

  for(i=1;i<150;i++)
    {
      square_table[i*i]=i;
      for(j=i+1;j*j+i*i<=20000;j++)
	square_sum_table[i*i+j*j]=-1;
    }
}
int find_square_sum(int x)
{
  int i;

  for(i=x+1;i<=20000;i++)
    if(square_sum_table[i])
      return(i);
  return(-1);
}
int find_same_shahen(int s2,int h,int *h2,int *w2)
{
  int i,hen2,sq;

  //printf("s2,h=%d %d\n",s2,h);

  for(i=h+1;i*i<=s2/2;i++)
    {
      hen2=s2-i*i;
      if((sq=square_table[hen2]))
	{
	  *h2=i;
	  *w2=sq;
	  return(-1);
	}
    }
      return(0);
}
main()
{
  int shahen2,w2,h2,next;
  make_square_sum();

  // printf("%d\n",find_square_sum(85));
  
  while(scanf("%d %d",&h,&w) && (w || h))
    {
      shahen2=w*w+h*h;

      if(!find_same_shahen(shahen2,h,&h2,&w2))
	{
	  next=find_square_sum(shahen2);
	  // printf("next=%d\n",next);
	  find_same_shahen(find_square_sum(shahen2),0,&h2,&w2);
	}
      printf("%d %d\n",h2,w2);
    }
  
  return(0);
}