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

	while(1){
	    scanf("%d%d", &h, &w); 
	    if(h == 0 && w == 0)break;
	    
		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) && (nh > h))
				           || ((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;
}