At the 3 minute mark team A takes 2 minor penalties and team B also takes 2 minor penalties. They should cancel each other out and the teams would still be playing 5 on 5 at that point. The team A player would have to sit 4 minutes and a whistle and the team B players would both sit 2 and a whistle, but no time would go on the clock.
Then, at 4:00 minutes team A gets another minor penalty. It's now 5 on 4 for team B. When team B scores at 4:45, they're on the PP. Player X still has to sit in the box for at least another 2:15 (they'll be out at the first whistle after the 7 minute mark). Player Z only has 1:15 left on their penalty. Player Z would come out of the box.