#include <bits/stdc++.h>
using namespace std;
int n, m, p;
int main() {
  cin >> n >> m;
  p = n * m;
  for (int i = 1; i <= 9; i++)
    if (p % i == 0)
      if (p % i <= 9) {
        printf("%d", p);
        return 0;
      }
  printf("-1");
  return 0;
}
