#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b, n, c = 0;
  cin >> a;
  cin >> b;
  n = a * b;
  for (int i = 1; i <= 9; i++) {
    if (n % i == 0 && n / i <= 9) {
      c++;
    }
  }
  if (c > 0)
    cout << n << endl;
  else
    cout << "-1" << endl;
}
