Playing with cards in stack

why is it giving run error on first two test case??
code link : https://ide.codingblocks.com/s/319145

Using prime sieve, you have to store all the prime numbers upto 10^5.
But you are storing prime numbers only upto 29.
You can refer this implementation https://ide.codingblocks.com/s/319264

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.