Leha and Function

CodeForces - 841C