/* 
   AOJ ICPC
   1186
   
 */
#include<stdio.h>
#include<stdlib.h>

struct node
{
  int height, width, diagonal;
  struct node *next;
};

struct node *head = NULL;

int target_height, target_width;

void trav()
{
  struct node *point;

  for(point = head; point != NULL; point = point->next)
    {
      printf("h %d, w %d, d %d\n", point->height, point->width, point->diagonal);
    }
}

void insert(int width, int height)
{
  int diagonal = height * height + width * width;
  struct node *new = malloc(sizeof(*new)), *next = head, *prev = head;
  if(head == NULL)
    {
      head = new;
      new->height = height;
      new->width = width;
      new->diagonal = diagonal;
      new->next = NULL;
    }
  else
    {
      while(next != NULL && next->diagonal <= diagonal)
	{
	  if(next->diagonal == diagonal && next->height > height)
	    {
	      break;
	    }
	  prev = next;
	  next = next->next;
	}
      prev->next = new;
      new->height = height;
      new->width = width;
      new->diagonal = diagonal;
      new->next = next;
    }
}


void make_up_list(void)
{
  int i, j;
  for(i = 1; i <= 150; i++)
    {
      for(j = 1; j < i; j++)
	{
	  insert(i, j);
	}
    }
  //  trav();
}

void search_ans(int height, int width)
{
  int diagonal = height * height + width * width;
  struct node *point = head;

  while(1)
    {
      if(height == point->height && width == point->width)
	{
	  break;
	}
      point = point->next;
    }
  target_height = point->next->height;
  target_width = point->next->width;
}

int main(void)
{
  make_up_list();

  int height, width;

  while(1)
    {
      scanf("%d %d", &height, &width);
      if(height == 0 && width == 0)
  	{
  	  break;
  	}
      search_ans(height, width);
      printf("%d %d\n", target_height, target_width);
    }
  return 0;
}