# Enter your code here. Read input from STDIN. Print output to STDOUT
a,b,c,d = (int(input()) for _ in range(4))
print (pow(a,b)+pow(c,d))

# Enter your code here. Read input from STDIN. Print output to STDOUT
a,b,c,d = (int(input()) for _ in range(4))
print (pow(a,b)+pow(c,d))

# Enter your code here. Read input from STDIN. Print output to STDOUT