#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#include <bits/stdc++.h>
using namespace std;
template<class t> inline t read(t &x){
	char c=getchar();bool f=0;x=0;
	while(!isdigit(c)) f|=c=='-',c=getchar();
	while(isdigit(c)) x=(x<<1)+(x<<3)+(c^48),c=getchar();
	if(f) x=-x;return x;
}
template<class t,class ...A> inline void read(t &x,A &...a){
	read(x);read(a...);
}
template<class t> inline void write(t x){
	if(x<0) putchar('-'),write(-x);
	else{if(x>9) write(x/10);putchar('0'+x%10);}
}

int ans,x,y;

signed main(){
	read(x,y);
	if(x==1) ans+=3e5;
	if(x==2) ans+=2e5;
	if(x==3) ans+=1e5;
	if(y==1) ans+=3e5;
	if(y==2) ans+=2e5;
	if(y==3) ans+=1e5;
	if(x==1&&y==1) ans+=4e5;
	write(ans);
}
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>

struct set {
	int h;
	int w;
	int diagonel;
} all[22500];

int suffix = 0;

void InsSort(int n)
{
	int i, j, temp_dia, temp_h, temp_w;

	for (i = 1; i < n; i++) {
		temp_h = all[i].h;
		temp_w = all[i].w;
		temp_dia = all[i].diagonel;
		for (j = i; j > 0; j--) {
			if (all[j - 1].diagonel > temp_dia) {
				all[j].h = all[j - 1].h;
				all[j].w = all[j - 1].w;
				all[j].diagonel = all[j - 1].diagonel;
			}
			else if (all[j - 1].diagonel == temp_dia) {
				if (all[j - 1].h > temp_h) {
					all[j].h = all[j - 1].h;
					all[j].w = all[j - 1].w;
					all[j].diagonel = all[j - 1].diagonel;
				}
				else {
					break;
				}
			}
			else {
				break;
			}
		}

		all[j].h = temp_h;
		all[j].w = temp_w;
		all[j].diagonel = temp_dia;
	}
}

void search() {
	for (int i = 1; i <= 150; i++) {
		for (int j = 1; j <= 150; j++) {
			if (i >= j) {
				continue;
			}

			all[suffix].h = i;
			all[suffix].w = j;
			all[suffix].diagonel = (i * i) + (j * j);

			suffix++;
		}
	}
}

int main() {
	search();
	InsSort(suffix);

	//FILE *fp;
	//fp = fopen("C:\\Users\\owata\\Desktop\\answer1.txt", "w");

	while (1) {
		int h, w, my;

		scanf("%d %d", &h, &w);

		if (h == 0 && w == 0) {
			break;
		}

		my = (h * h) + (w * w);

		for (int i = 0; i < suffix; i++) {
			if (all[i].h == h && all[i].w == w) {
				continue;
			}

			if (all[i].diagonel > my) {
				printf("%d %d\n", all[i].h, all[i].w);
				//fprintf(fp, "%d %d\n", all[i].h, all[i].w);
				break;
			}
			else if (all[i].diagonel == my && h < all[i].h) {
				printf("%d %d\n", all[i].h, all[i].w);
				//fprintf(fp, "%d %d\n", all[i].h, all[i].w);
				break;
			}
		}
	}

	//fclose(fp);

	return 0;
}