#include <bits/stdc++.h>
using namespace std;
vector<int> v = {1,  2,  3,  4,  5,  6,  7,  8,  9,  10, 12, 14,
                 16, 18, 15, 21, 24, 27, 20, 28, 32, 36, 25, 30,
                 35, 40, 45, 42, 48, 54, 49, 56, 63, 64, 72, 81};
int main() {
  int a, b, c;
  cin >> a, b;
  c = a * b;
  auto r = find(v.begin(), v.end(), c);
  if (r == v.end()) {
    cout << -1;
  } else {
    cout << c;
  }
  cout << endl;
}
