rt(qp=quickpow)
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int b,p;
int qp(int x,int y){
ll ans=1;
while(y){
if(y%2==1) ans=1LL*ans*x;
x=1LL*x*x;
y/=2;
}
return ans;
}
int main(){
cin>>b>>p;
ll v=qp(b,p);
if(v>1e9) cout<<-1;
else cout<<v;
return 0;
}