#include <stdio.h>

int main(){
  int h, w, t2, t2_a, i, j, h_a, w_a, ans;

  while(1){
    scanf("%d %d", &h, &w);
    if( (h == 0)&&(w == 0)) break;

    t2 = h*h + w*w;

    h_a = w_a = 0;
    ans = 22500;
    for(i = 1; i <= 149; i++){
      for(j = i+1; j <= 150; j++){

        t2_a = i*i + j*j;

        if( t2 <= t2_a ){
          if(h == i && w == j ) continue;
          if(t2 == t2_a){
              if(h >= i) continue;
          }
          if(t2_a < ans){
            h_a = i;
            w_a = j;
            ans = t2_a;
          }
        }

      }
    }

    printf("%d %d\n", h_a, w_a);
  }


  return 0;

}

