The law of conservation of momentum gives
Hence, the initial velocity of block and bullet is
The change of energy