Team A is throwing the ball in. They do a mass substitution and end up with 6 players on the court. The refs do not notice until after team A is fouled on a shot at which point they call a technical on Team A.

Does team A get to shoot their free throws for the foul? Or does the play not count and Team B gets to shoot the technical free throws?

Edit: Found answer on officiating site. All play until discovery counts. Team A shoots free throws for the foul then team B shoots technical shots