For sure the first ‘solution’ would not be within the ‘spirit’ or fairness of the Laws!!
In reality, this is a purely theoretical question, except perhaps on a small field (ie young children playing).
The ‘spirit’ or ‘intention’ underlying every Law is crucial here as in any other debate. The recent changes to Law 12 have ‘banned’ scoring ‘accidentally’ with the hand or arm. Thus allowing the goal is not within this approach.
Although not technically ‘throwing’, the ‘intention’ of that part of the Law is that a goalkeeper cannot score with their hands (even though they can handle the ball in their own penalty area) as the underlying principle (which includes not allowing a goal directly from a throw-in) is that a goal cannot be scored directly from the hand/arm of any player of the attacking team.
Therefore, the ‘fairest’ outcome would be a goal kick.
To reiterate, Law application and interpretation should always be based on the ‘spirit’ and the ‘intention’ of the Law and not necessarily an over-precise definition of each word. This is especially important as some words in the English text are chosen more for ease of translation that ‘legal’ accuracy.