**n objects**are arranged in a circle and every

**mth object**is deleted until 1 object is left.

The original problem is said to derive from a suicide pact among 41 rebels trapped by the Romans in the first century. The rebels decided to kill every third person until one is left and can escape in a boat that can take only one person. Josephus, the historian who lived to tell the story quickly figured out where he should position himself from the starting point in the circle so that he would survive.

Suppose you were in that situation with the only difference that you have your palm PC to quickly find out the lucky position to survive. Your program should be able to handle the following situation:

n people (n > 0 ) are initially arranged in a circle, facing inwards, and numbered from 1 to n. The numbering from 1 to n proceeds consecutively in a clockwise direction.

Starting with person number 1, counting continues in a clockwise direction, until we get to person number k (k > 0), who is promptly killed.

Counting then proceeds from the person to his immediate left, to kill the kth person, and so on, until only one person remains.

For example, when n = 5 and k = 2, the order of execution is 2, 4, 1, and 5. The survivor is 3.

Hint you have to implement the circular list for your program to be efficient."how that could be !"

**Input**

Input data is to be read from a file roulette.in. Each line in this file contains values for n and k (in that order). A line containing values of 0 for n and k will terminate input. Your program does know not the maximum number of people taking part in this tragic event.

Output

For each input line, output in a file roulette.out the position of the sole survivor.

Sample Input

1 1

1 5

8 3

0 0

Sample Output

1

1

7

- to be serious with you my friends i did not understand this question very well !

and am not here to just get the solution without learning!

.. i know here a lot of people who have excellent background they can help

me step by step. so please will you help me !! to learn and solve this problem !