A lighthouse stands vertically on the sea coast. From a ship positioned due west of the lighthouse, the angle of elevation of the top of the lighthouse is 30∘. After the ship sails 500m directly towards the lighthouse, the angle of elevation becomes 45∘. Determine the height of the lighthouse.