#include <stdio.h>
#include <stdbool.h>

bool less_than(int h1, int w1, int h2, int w2)
{
	int s = h1*h1 + w1*w1;
	int t = h2*h2 + w2*w2;

	return s < t || (s == t && h1 < h2);
}	

int main(void)
{
	for (;;) {
		int h, w;
		int ans_h, ans_w;

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

		ans_h = 150;
		ans_w = 150;
		for (int i = 1; i <= 150; i++) {
			for (int j = i+1; j <= 150; j++) {
				if (less_than(h, w, i, j) && less_than(i, j, ans_h, ans_w)) {
					ans_h = i;
					ans_w = j;
				}
			}
		}

		printf("%d %d\n", ans_h, ans_w);
	}
	return 0;
}