/**
 * AOJ #1186: Integral Rectangles (ICPC Domestic 2013)
 */

#include <stdio.h>

#define MAX_HW 150
#define DIAG2(h, w) ((h) * (h) + (w) * (w))
#define LT(h1, w1, h2, w2) (DIAG2((h1), (w1)) < DIAG2((h2), (w2)) || \
                           (DIAG2((h1), (w1)) == DIAG2((h2), (w2)) && \
                           (h1) < (h2)))

/**
 * Print the smallest wide integral rectangle bigger than the given one.
 */
void solve(int h, int w)
{
  int h1, w1, minh, minw;
  minh = minw = MAX_HW;
  for (h1 = 1; h1 <= MAX_HW; h1++) {
    for (w1 = h1 + 1; w1 <= MAX_HW; w1++) {
      if (LT(h, w, h1, w1)) {
        if (LT(h1, w1, minh, minw)) {
          minh = h1;
          minw = w1;
        }
      }
    }
  }
  printf("%d %d\n", minh, minw);
}

int main()
{
  int h, w;
  for (;;) {
    scanf("%d%d", &h, &w);
    if (h == 0 && w == 0) break;
    solve(h, w);
  }
  return 0;
}