The only amendments I am aware of to the axiom - "The game cannot end on an accepted penalty" are
Please read rule 3-2-3-a. The only situations where the period is extended are if there is a
live-ball foul and the penalty is accepted, there are offsetting fouls, there is an inadvertent whistle, or a touchdown is scored (extend only for the try). A dead-ball foul does
not cause the period to be extended.
In the original play situation, game over, team B wins.