#include <stdio.h>
#include <stdlib.h>
#define N 1000000

// if (h2,w2) is bigger than (h1, w1) then return positive num;
int big(int h1,int w1,int h2,int w2){
  int d1, d2;
  d1 = h1*h1 + w1*w1;
  d2 = h2*h2 + w2*w2;
  if(d1==d2){
    return h2-h1;
  }
  return d2-d1;
}

int main(void){
  int n,i,j,d1,d2,mind,minw,minh;
  int h,w;
  while(1){
    scanf("%d %d",&h, &w);
    if(h==0 && w==0)break;
    d1 = h*h + w*w;
    minh=minw = 10000;
    for(i = 1 ; i <= 150 ; i++){
      for(j = i+1 ; j <= 150 ; j++){
	if(big(h,w,i,j) > 0){
	  if(big(i,j,minh,minw) > 0){
	    minh = i;
	    minw = j;
	  }
	}
      }
    }

    printf("%d %d\n", minh, minw);
  }
    
  return 0;
}