I am solving Snackdown’s practice problem ARRGRAPH. I use python and wrote the correct code. I tested it for boundary cases and exceptions and it works fine. Yet, I am getting the wrong answer.

Here is my code. Hope someone will tell me whats going on.

```
# cook your dish here
from math import gcd
for t in range(int(input())):
N = int(input())
A = list(map(int, input().split()))
primes = []
others = []
max_prime = 0
B = []
temp = A[0]
spcl = 0
while A:
B.append(A[0])
if A[0] == temp:
spcl += 1
if ((A[0] - 1)/6).is_integer() or ((A[0] + 1)/6).is_integer() or A[0] == 2 or A[0] == 3:
prime = A.pop(0)
if prime > max_prime:
max_prime = prime
primes.append(prime)
elif A[0] < max_prime:
A.pop(0)
else:
others.append(A.pop(0))
i = 0
while i < len(others):
for prime in primes:
if gcd(others[i], prime) == 1:
others.pop(i)
i -= 1
break
i += 1
if len(others) == 0 and spcl != N:
print(0)
elif len(others) == 0 and spcl == N:
print(1)
if B[0] == 47:
B[0] = 41
else:
B[0] = 47
else:
print(1)
B[0] = 47
print(*B)
```