import std.stdio, std.conv, std.string, std.algorithm, std.array, std.container, std.format;

class Rectangle {
  int h;
  int w;
  
  this( int h, int w ) {
	this.h = h;
	this.w = w;
  }
  
  override int opCmp( Object o ) {
	Rectangle r = cast(Rectangle)o;
	immutable int diag = h * h + w * w;
	immutable int rDiag = r.h * r.h + r.w * r.w;
	if ( diag != rDiag ) {
	  return diag - rDiag;
	} else {
	  return h - r.h;
	}
  }

  override string toString() {
	return format( "%d %d", h, w );
  }
}

void main()
{
  auto tree = new RedBlackTree!Rectangle();
  foreach ( h; 1 .. 151 ) {
	foreach ( w; h + 1 .. 151 ) {
	  tree.insert( new Rectangle( h, w ) );
	}
  }

  while ( true ) {
	string input = readln;
	int h, w;
	formattedRead( input, "%d %d\n", &h, &w );
	if ( h == 0 && w == 0 ) break;
	auto rng = tree.upperBound( new Rectangle( h, w ) );
	writeln( rng.front );
  }
}