My first thought was in the controller. Then after further thinking...... it is uploaded from the controller to the drone.
Why I came to this conclusion is because if the drone drops contact with the controller (and if set ) it has the details stored to enable it to complete the task and then RTH.
I could be wrong but the master file is stored in your phone/monitor/ Crystalsky monitor and is uploaded to the drone after you have selected which flight you want each time you fly. You could have dozens of waypoint flights stored and there would not be enough memory if all stored in the drone. If this is true I would think that the info could be upload to a similar drone.