a=eval(input())

a=int(a)

print((a+a*a+a*a*a))
a=int(eval(input()))

print((a+a*a+a**3))
a = eval(input())
a = int(a)
print((a + a * a + a * a * a))

a = int(eval(input()))
print((a + a * a + a**3))

-a = eval(input()) -a = int(a) -print((a + a * a + a * a * a)) +a = int(eval(input())) +print((a + a * a + a**3))