when the top of the pencil moves in one direction, the bottom end on the ground will move in another, but due to the frictional force it will move by a lesser amount, and the center of mass of the pencil will be accelerated in the horizontal direction due to the force of friction