Bullet and Block

A bullet of mass m is fired horizontally with a speed v into a wooden block of mass M.

A. If the bullet is stopped in the block, how fast is the block moving after the collision?

B. If the bullet exits the block with a speed v/2, how fast is the block moving after the collison?