Glad I put this out there for discussion.
(First, check the ‘setup;’ I did set this in the 4th period.)
Technically, there are three possibilities.
1) Team B is free from foul before gaining possession (“clean hands”), so they MAY refuse offsetting fouls (thus, declining A’s penalty, by rule), and then Team A can accept OR decline B’s penalty. If A accepts B’s penalty, then B gets the ball where the penalty leaves it, for an untimed down. The Basic Spot (end of the related run ) is the A-40, and the spot of the foul is behind the Basic Spot, so the B penalty would be enforced from the spot of the foul (50), taking the ball to the B-40, 1/10, untimed down. There is no way Team A would allow this to happen, because (see 2),
2) Team B is free from foul before gaining possession (“clean hands”), so they MAY refuse offsetting fouls (thus, declining A’s penalty, by rule), and then Team A can accept OR decline B’s penalty. If A declines B’s penalty - game over. Team B would not want that to happen.
3) Team B can accept offsetting fouls, and the down would be repeated at the previous spot, with an untimed down in the extended period. Team B MIGHT do this, in hopes that something might happen that would allow them to score. But, all Team A needs to do is take the snap and take a knee - game over. This is the most likely scenario.
So, bottom line is that Team A is really in control of this situation, and they would have to make a monumental mistake to lose this game.
(Don’t know what would happen in other rule sets, but those are what could happen in NCAA.)