#include <bits/stdc++.h>
using namespace std;
const int maxn = 100005;
int num[maxn];
int main(void) {
  for (int i = 1; i <= 9; i++) {
    for (int j = 1; j <= i; j++) {
      num[i * j] = 1;
    }
  }
  int first, second;
  scanf("%d%d", &first, &second);
  if (num[first * second])
    printf("%d\n", second * first);
  else
    printf("-1\n");
  return 0;
}
