Playing with cards in stack

please explain what to do in this chsllange

Hi,

Follow the following steps:

  1. Take input in a stack.
  2. one by one pick the element of stack and check its divisibility with first prime.
  3. if number is divisible put in stack(say A) and the others in stack B.
  4. print the numbers in stack A.
  5. Follow same process for stack B again but now you should check divisibility with second prime.

Again after whole process check divisibility with third prime and so on until q queries.