Computing the Teichmüller polynomial