import std.stdio, std.conv, std.string;

void main(){
	while(1){
		string[] input = split(readln());
		int h = to!int(input[0]);
		int w = to!int(input[1]);

		if(h == 0 && w == 0) break;
		double diag = h*h + w*w;
		double ah = 151;
		double aw = 151;

		auto setAns = delegate void(int ht, int wt) {
			auto digt = ht*ht + wt*wt;
			auto diga = ah*ah + aw*aw;
			if(digt < diga){
				ah = ht;
				aw = wt;
			}else if(digt == diga && ht < ah){
				ah = ht;
				aw = wt;
			}
		};

		foreach(i ; 1 .. 151){
			foreach(j ; i+1 .. 151){
				auto dig2 = i*i + j*j;
				if(diag < dig2){
					setAns(i, j);
				}else if(diag == dig2 && h < i){
					setAns(i, j);
				}
			}
		}

		writeln(ah, ' ', aw);
	}
}