import std.string;
import std.algorithm;
import std.math;
import std.array;
import std.format;
import std.range;
import std.stdio;
import std.conv;

int pred(int h, int w, int H, int W)
{
    int r2 = h^^2 + w^^2;
    int R2 = H^^2 + W^^2;
    if(r2 == R2) return h - H;
    else return r2 - R2;
}


void main()
{
    while(1){
        auto hw = readln().chomp().split().map!(to!uint),
             H = hw[0],
             W = hw[1];

        if(!H) break;

        uint resH = 150, resW = 150;

        foreach(h; 1 .. 150)
            foreach(w; h+1 .. 150){
                if(pred(h, w, H, W) > 0 && pred(h, w, resH, resW) < 0){
                    resH = h;
                    resW = w;
                }
            }

        writefln("%s %s", resH, resW);
    }
}