#include<iostream>
#include<string>
#include<math.h>
using namespace std;
int main(){
	int h,w,s;
	while(true){
	cin>>h>>w;
	if(h==0&&w==0)
		break;
	bool t=true;
	s=h*h+w*w;
	h++;
	while(true){
		if(h*h>=s-h*h)
			break;
		if(s==h*h+(int)sqrt((double)s-h*h+0.0)*(int)sqrt((double)s-h*h+0.0)){
			t=false;
			break;
		}
		h++;
	}
	s++;
	if(t==true){
	while(true){
		h=1;
		while(true){
		if(h*h>=s-h*h)
			break;
		if(s==h*h+((int)sqrt((double)s-h*h+0.0)*(int)sqrt((double)s-h*h+0.0))){
			t=false;
			break;
		}
		h++;
		}
		if(t==false)
			break;
		s++;
	}
	}
	cout<<h<<" "<<(int)sqrt((double)s-h*h+0.0)<<endl;
	}
	return 0;
}
#include <iostream>
#include <vector>
#include <cstring>
#include <algorithm>
using namespace std;
struct rect{
  int w,h,v;
  bool operator<(const rect& a) const{
    return v==a.v ? h < a.h : v < a.v;
  }
};
int main(){
  int i,j,k,w,h;
  vector <rect> rs;
  rect r;
  for(i=1;i<151;i++){
    for(j=1;j<i;j++){
      r.w=i;
      r.h=j;
      r.v=i*i+j*j;
      rs.push_back(r);
    }
  }
  sort(rs.begin(),rs.end());
  cin >> h >> w;
  while(h!=0){
    for(i=0;i<rs.size();i++){
      if(rs[i].w==w&&rs[i].h==h) cout << rs[i+1].h << " " << rs[i+1].w << endl;
    }
    cin >> h >> w;
  }
  return 0;
}