#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b;
  cin >> a >> b;
  if (a * b > 81) {
    cout << -1;
    return 0;
  }
  int c = a * b;
  for (int i = 2; i * i <= c; i++) {
    int wtf = 0;
    while (c % i == 0) {
      c /= i;
      wtf = i;
    }
    if (i > 9) {
      cout << -1;
      return 0;
    }
  }
  if (c > 9) {
    cout << -1;
    return 0;
  }
  cout << a * b;
}
