#include <stdio.h>
#include <stdlib.h>

#define MAX_SIZE 150

int diagonal2(int h, int w) {
	return h * h + w * w;
}

// (h1, w1)?????´????????¢???(h2, w2)?????´????????¢??????????°?????????£??????1????????????????????§???????????°0????????????
int less(int h1, int w1, int h2, int w2) {
	const int d1 = diagonal2(h1, w1);
	const int d2 = diagonal2(h2, w2);
	if(d1 != d2) return d1 < d2;
	return h1 < h2; // ??????
}

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

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

		ans_h = MAX_SIZE + 1;
		ans_w = MAX_SIZE + 1;

		for(i = 1; i <= MAX_SIZE; ++i) {
			for(j = i + 1; j <= MAX_SIZE; ++j) {
				int h2 = i;
				int w2 = j;

				if(less(h, w, h2, w2) && less(h2, w2, ans_h, ans_w)) {
					ans_h = h2;
					ans_w = w2;
				}
			}
		}

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

	return EXIT_SUCCESS;
}