Playing with cards

two test cases are getting failed!! why?

Hello @rockstarpkm,

Your code is failing for test cases like:
7 2
3 4 7 6 5 8 9
Expected Output:
4
6
8
9
3
5
7
Your Output:
9
3
4
6
8
5
7

Correct your code.
You are printing your stacks incorrectly,
It is failing for test cases with q>1.

You can refer to the following code:

Let me know if you still face any issue.
I’ll correct your code.