I need help for this question... plz...

PART B: JOSEPHUS PROBLEM

Consider the following scenario - a group of soldiers surrounded by an overwhelming enemy force. There is no hope for victory without reinforcements, but there is only a single horse available for escape. The soldiers agree to a pact to determine which of them is to escape and summon help. They stand in a circle and each picks a number from a hat. One of their names is also picked from the hat. Starting with the soldier whose name is picked and the nth number he chose, they count around the circle clockwise and eliminate the nth person. The number that this soldier chose is then used to continue the count. Each time that a soldier is eliminated, the number that he chose is then used to continue the count. Any soldier removed from the circle is no longer counted. The last soldier remaining is to take the horse and escape.

The input to the program is a list of names, which is the clockwise ordering of the circle beginning with the soldier from whom the count is to start. The program must print the names in the order in which they are eliminated and the name of the soldier who escapes.