```
import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;

public class forA1 {
     public static void main(String[] args) throws Exception{
            Scanner sc = new Scanner(System.in);
            String []num = sc.nextLine().split(" ");
            int n = Integer.parseInt(num[0]);
            int m = Integer.parseInt(num[1]);

            while(n != 0){
                // initialize the queue
                Queue<Integer> queue = new LinkedList<Integer>();
                queue.clear();
                for (int i = 1; i <= n; i++)
                    queue.add(i);

                //int res = 0;
                while (!queue.isEmpty()) {
                    for (int i = 0; i < m-1; i++)
                        queue.add(queue.remove());
                    queue.remove();
                }
                //System.out.println(res);
                //System.out.println(res);

                System.out.print(queue);

                String []num2 = sc.nextLine().split(" ");
                n = Integer.parseInt(num2[0]);
                m = Integer.parseInt(num2[1]);
            }
        }
}

```

When I insert 2 numbers, it will print out [].Can some please explain to me why this happens, I'm a student, so I apologize if I'm asking a question that is easy for others.