Integers in Python can be as big as the bytes in your machine's memory. There is no limit in size as there is: $2^{31}-1$ (c++ int) or $2^{63}-1$ (C++ long long int).    

As we know, the result of $a^{b}$ grows really fast with increasing $\boldsymbol{b}$.  

Let's do some calculations on very large integers.  

Task 

Read four numbers, $\boldsymbol{\alpha}$, $\boldsymbol{b}$, $\boldsymbol{c}$, and $\boldsymbol{d}$, and print the result of $a^b+c^d$.  

Input Format 

Integers $\boldsymbol{\alpha}$, $\boldsymbol{b}$, $\boldsymbol{c}$, and $\boldsymbol{d}$ are given on four separate lines, respectively.

Constraints 

$1\leq a\leq1000$ 

$1\leq b\leq1000$ 

$1\leq c\leq1000$ 

$1\leq d\leq1000$  

Output Format 

Print the result of $a^b+c^d$ on one line.  

Sample Input  

9
29
7
27

Sample Output  

4710194409608608369201743232  

Note: This result is bigger than $2^{63}-1$. Hence, it won't fit in the long long int of C++ or a 64-bit integer.

Source: hackerrank | Difficulty: EASY
Tags: Mathematics


Solutions:
a = int(input().strip())
b = int(input().strip())
c = int(input().strip())
d = int(input().strip())
print(pow(a, b) + pow(c, d))


a = int(input())
b = int(input())
c = int(input())
d = int(input())
m = pow(2, 63) - 1
print(pow(a, b) + pow(c, d))


(a, b, c, d) = (int(input()) for _ in range(4))
print(pow(a, b) + pow(c, d))


(a, b, c, d) = [int(input()) for _ in '1234']
print(pow(a, b) + pow(c, d))


a = int(input())
b = int(input())
c = int(input())
d = int(input())
print(pow(a, b) + pow(c, d))


def calculate():
	a = int(input())
	b = int(input())
	c = int(input())
	d = int(input())
	result = a ** b + c ** d
	print(result)
calculate()


from textwrap import wrap
from cmath import phase
from math import sqrt, acos, degrees

def getInt():
	return int(input())

def getFloat():
	return float(input())

def getStr():
	return input()

def getIntList(split=' '):
	return list(map(int, input().split(split)))

def printListVertical(arr):
	for x in arr:
		print(x)

def unique(arr):
	return list(set(arr))

def uniqueOrdered(arr):
	return sorted(set(arr), key=lambda x: arr.index(x))
a = getInt()
b = getInt()
c = getInt()
d = getInt()
print(a ** b + c ** d)


a = int(input())
b = int(input())
c = int(input())
d = int(input())
p = a ** b
q = c ** d
res = p + q
print(res)


print(pow(int(input()), int(input())) + pow(int(input()), int(input())))


import math
one = int(input())
two = int(input())
three = int(input())
four = int(input())
print(pow(one, two) + pow(three, four))


def __starting_point():
	a = int(input().strip())
	b = int(input().strip())
	c = int(input().strip())
	d = int(input().strip())
	print(pow(a, b) + pow(c, d))
__starting_point()


numbers = []
max_numbers = 4

def calculate(numbers):
	res = 0
	for number in numbers:
		if not number >= 1 or not number <= 1000:
			return
	res = pow(numbers[0], numbers[1]) + pow(numbers[2], numbers[3])
	print(res)
while len(numbers) < max_numbers:
	numbers.append(int(input()))
calculate(numbers)


import math
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = pow(a, b) + pow(c, d)
print(e)


a = int(input())
b = int(input())
c = int(input())
d = int(input())
A = a ** b + c ** d
print(A)


nums = []
for _ in range(0, 4):
	nums.append(int(input()))
print(pow(nums[0], nums[1]) + pow(nums[2], nums[3]))


(a, b, c, d) = [int(input()) for _ in range(4)]
print(pow(a, b) + pow(c, d))


import sys
import math
a = int(input())
b = int(input())
c = int(input())
d = int(input())
print(pow(a, b) + pow(c, d))


a = int(input())
b = int(input())
c = int(input())
d = int(input())
print(a ** b + c ** d)


(a, b, c, d) = [int(input()) for i in range(4)]
print(a ** b + c ** d)


a = int(input().strip())
b = int(input().strip())
c = int(input().strip())
d = int(input().strip())
print(a ** b + c ** d)


(a, b, c, d) = [int(input()) for _ in range(4)]
print(a ** b + c ** d)


import math
(a, b, c, d) = (int(input()) for _ in range(4))
print(pow(a, b) + pow(c, d))


a = eval(input())
b = eval(input())
c = eval(input())
d = eval(input())
print(a ** b + c ** d)


(a, b, c, d) = (int(input()), int(input()), int(input()), int(input()))
print('{}'.format(pow(a, b) + pow(c, d)))


(a, b, c, d) = (int(input()), int(input()), int(input()), int(input()))
print(pow(a, b) + pow(c, d))


(a, b, c, d) = [int(input()) for _ in '1234']
print(a ** b + c ** d)


(a, b, c, d) = (int(input()), int(input()), int(input()), int(input()))
print(a ** b + c ** d)


a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = pow(a, b) + pow(c, d)
print(e)


print(int(input()) ** int(input()) + int(input()) ** int(input()))


a = int(input())
b = int(input())
c = int(input())
d = int(input())
o = a ** b + c ** d
print(o)


a = int(input())
b = int(input())
c = int(input())
d = int(input())
if 1 <= a <= 1000 and 1 <= b <= 1000 and (1 <= c <= 1000) and (1 <= d <= 1000):
	print(str(a ** b + c ** d))