#define _CRT_SECURE_NO_WARNINGS
//#define _USE_MATH_DEFINES
#include<stdio.h>
//#include<stdlib.h>
#include<math.h>
//#include<string.h>
//#include<time.h>
//#define pi acos(-1.0)
#define P(type,x) fprintf(stdout,"%"#type"\n",x)
int main() {
	int i, j, h, w, s;
	while (fscanf(stdin, "%d%d", &h, &w), h || w) {
		s = h*h + w*w;
		i = h + 1;
		while (1) {
			for (; i*i < s; i++) {
				for (j = i + 1; j*j + i*i <= s; j++)
					if (i*i + j*j == s) goto e;
			}
			s++, i = 1;
		}
		e:
		fprintf(stdout, "%d %d\n", i, j);
	}
	return 0;
}