import math x,a,y,b=map(int,input().split()) if math.gcd(x,y)==1 and pow(x,a)