a = int(eval(input()))

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

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

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

-print((a + a * a + a * a * a)) +print((a + a * a + a**3))