#include <cstdio>
#include <cmath>

using namespace std;

int main(void)
{
    int h, w;
    int h2;
    double w2;
    for (;;) {
	scanf("%d %d", &h, &w);
	if (h == 0 && w == 0)
	    return 0;

	int z = pow(h, 2) + pow(w, 2);
	w2 = sqrt(z);
	for(h2 = h+1; h2 < w2; h2++) {
	    w2 = sqrt(z - pow(h2, 2));
	    if (w2 == static_cast<int>(w2))
		break;
	}
	if(w2 <= h2) {
	    z++;
	    for (int flag = 0; flag == 0; z++) {
		for(h2 = 1; pow(h2,2) < z/2; h2++) {
		    w2 = sqrt(z - pow(h2, 2));
		    if (w2 == static_cast<int>(w2)) {
			flag = 1;
			break;
		    }
		}
	    }
	}
	printf("%d %d\n", h2, static_cast<int>(w2));
    }
}
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "iomanip"
#include "random"

using namespace std;

const long long int MOD = 1000000007;
const long double EPS = 0.00000001;
const long double PI = 3.1415926535897932384626433;

long long int N, M, K, H, W, L, R;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);

	vector<pair<int, pair<int,int>>>v;
	for (int i = 1; i <= 150; i++) {
		for (int j = i + 1; j <= 150; j++) {
			v.push_back({ i*i + j*j ,{i,j} });
		}
	}
	sort(v.begin(), v.end());
	cin >> H >> W;
	while (H) {
		bool flag = false;
		for (auto i : v) {
			if (flag) {
				cout << i.second.first << " " << i.second.second << endl;
				break;
			}
			if (i.second.first == H&&i.second.second == W) {
				flag = true;
			}
		}
		cin >> H >> W;
	}
	return 0;
}