Team A got the ball with clean hands and ended the down with the ball, so they will get the choice. They can choose to offset the fouls and replay the down, or they can choose to decline Team B's foul. If they decline Team B's foul, Team B will decline the IBB and the illegal touching will stand. Depending on field position, Team A's best bet is probably to just replay 4th down.