#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
using namespace std;

typedef pair<int, int> P;

bool compare(P a, P b) {
    if(a.first*a.first+a.second*a.second == b.first*b.first+b.second*b.second) return a.first < b.first;
    return a.first*a.first+a.second*a.second < b.first*b.first+b.second*b.second;
}


int main() {
    vector<P> vec;
    for(int i = 1; i <= 150; i++) {
        for(int j = i + 1; j <= 150; j++) {
            vec.push_back(P(i,j));
        }
    }
    sort(vec.begin(), vec.end(), compare);
    for(int h, w; cin >> h >> w, h || w; ) {
        int t;
        for(int i = 0; i < (int)vec.size(); i++) {
            if(P(h,w) == vec[i]) {
                t = i;
                break;
            }
        }
        cout << vec[t+1].first << ' ' << vec[t+1].second << endl;
    }
}
