The momentum exception is off since the ball came out of the end zone. The ball re-entering the end zone is the responsibility of Team A (due to the kick), and since the ball became dead there, the result of the play is a safety. The basic spot for enforcement for the illegal kick is the end of the related run, which is also in the end zone. If the penalty for the illegal kick is accepted, since the momentum exception does not apply, the penalty would be enforced from the basic spot, which is in the end zone, which is also a safety.
So, there is essentially no option here for Team B. Team B scores 2 points and Team A will put the ball in play with a free kick from the A 20-yard line.