#include <stdio.h>
int main(void) {
  int h,w,cross,x=0;
  int i=0,j=0,m=0,n=0,flag=0;   /*i:h  j:w*/
  while(scanf("%d%d", &h, &w) && (h != 0 || w != 0)) {

  if(h == 0 || w == 0) {
    break;
  }
  cross = h * h + w * w;
  for(i = h + 1; i <= 150; i++) {
    for(j = i + 1; j <= 150; j++) {
     if(i * i + j * j == cross) {
	x = cross;
	flag = 1;
	m = i;
	n = j;
	break;
      }
    }
    if(flag == 1) break;
  }


  while(1) {
    if(flag == 0) {
      cross++;
      for(i = 1; i <= 150; i++) {
	for(j = i + 1; j <= 150; j++) {
	  if(i * i + j * j == cross) {
	    x = cross;
	    m = i;
	    n = j;
	    flag = 1;
	    break;
	  }
	}
	if(flag == 1) break;
      }
    } else{
      break;
    }
  }
  flag = 0;
  printf("%d %d\n", m, n);

  }
  return 0;
}