#include <stdio.h>
int main(int argc, char const *argv[]) {
	int h, w, nh, nw;

	while ((scanf("%d %d", &h, &w)) != EOF) {
		if (h == 0 && w == 0)return 0;
		int mh, mw = 150;

		int x = h * h + w * w;

		for (nh = 1; nh <= 150 ; nh++) {
			for (nw = nh + 1; nw <= 150; nw++) {
				
				if (nw * nw + nh * nh > mw * mw + mh * mh) {
					break;
				} else if ((nw * nw + nh * nh > x) &&
				           (nw * nw + nh * nh < mw * mw + mh * mh)) {
					mw = nw;
					mh = nh;
					break;
				}

			}
		}

		printf("%d %d\n", mh, mw);
	}

	return 0;
}