#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b;
	cin>>a>>b;
  if(a*b>81){ 
    cout<<-1;
  	return;
  }
  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;
    }
  }
  if(c>9){
    cout<<-1;
    return;
  }
  cout<<a*b;
}