Balls collide elastically, preserving total momentum and kinetic energy.
Momentum is not preserved when balls bounce off the walls, but KE is.