a = int(eval(input()))



print((a + (a * a) + (a * a * a)))

a = int(eval(input()))

print((a + a**2 + a**3))



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

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

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