a = int(eval(input()))

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

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

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

-print((a * ((a + 1) * (a + 1) - a))) +print((a + a * a + a * a * a))