#include <stdio.h>
#include <math.h>

int search( int, int );

int main( void ) {
	int h, w, dSq, d, ans;

	for ( ; scanf( "%d %d", &h, &w ), h; printf( "%d %d\n", ans / 151, ans % 151 ) ) {
		dSq = h * h + w * w;

		if ( ans = search( h + 1, dSq ) )
			continue;

		for ( d = dSq + 1; !( ans = search( 1, d++ ) );  ) ;
	}

	return 0;
}

int search( int ini, int d ) {
	int h, w;

	for ( h = ini; h * h * 2 < d; h++ ) {
		w = sqrt( d - h * h );

		if ( w * w == d - h * h )
			return h * 151 + w;
	}

	return 0;
}