#include <bits/stdc++.h>
#include <cstdio>
using namespace std;
int main(){
freopen("pow.in","r",stdin);
freopen("pow.out","w",stdout);
long long a , b;
scanf("%ld %ld" , &a , &b);
if(a == 1){
printf("1");
return 0;
}
if(b == 1){
printf("%ld" , a);
return 0;
}
if(a > 31622){
printf("-1");
return 0;
}
if(b > 29){
printf("-1");
return 0;
}
if(pow(a , b-1) > pow(10 , 9)){
printf("-1");
} else {
int c = pow(a , b);
printf("%ld" , c);
}
return 0;
}