#include <stdio.h>

int main() {
  int h, w;
  int output[2];
  int temp;
  int length;
  int answer;
  int i, j;

  while(1) {
    scanf("%d %d", &h, &w);
    if(h == 0 && w == 0) break;

    length = h * h + w * w;

    output[0] = 150; 
    output[1] = 150;
    answer = 150 * 150 * 2;

    for(i = 1; i < 150; i++) {
      for(j = i + 1; j < 150; j++) {
	if(i == h && j == w) continue;
	temp = i * i + j * j;
	if(temp > length) {
	  if(answer > temp) {
	    answer = temp;
	    output[0] = i;
	    output[1] = j;
	  }
	} else if(temp == length) {
	  if(temp == answer) {
	    if(output[0] > i && h < i) {
	      answer = temp;
	      output[0] = i;
	      output[1] = j;
	    }
	  } else {
	    if(h < i) {
	      answer = temp;
	      output[0] = i;
	      output[1] = j;
	    }
	  }
	}
      }
    }
    printf("%d %d\n", output[0], output[1]);
  }

  return 0;
}