#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int a, b;
cin >> a >> b;
if (a == 1) cout << 1 << endl;
else if (b == 1) cout << a << endl;
else if (b >= 27) cout << -1 << endl;
else if (a >= 31623) cout << -1 << endl;
else{
ll c = 1;
while(b > 0)
{
b --;
if (1e9 / (double)(c) < a && b != 0)
{
cout << -1 << endl;
return 0;
}
c *= a;
}
cout << c << endl;
}
return 0;
}