Doubt in MAKE_IT_ONE problem from today's contest

import math
for i in range(int(input())):
L,R=map(int,input().split())
ans=list(range(L,R))
ini=[R]
ans=ini+ans
if L%2==0 and R%2==0:
print(-1)
else:
if math.gcd(L,R)==1:
print(*ans, sep=’ ‘)
else:
first=ans[0]
second=ans[R-L-1]
ans[0]=second
ans[R-L-1]=first
print(*ans, sep=’ ')

can someone explain why is this code wrong? At what test case does it fail?

@chaityadaga
can u plzz explain your logic .
Plzz refer my c++ code for better understanding

#include <bits/stdc++.h>
using namespace std;

int main() {
	// your code goes here
	int t;
	cin>>t;
	while(t--)
	{
	    int l,r;
	    cin>>l>>r;
	    int n=r-l+1;
	    if(n%2&&l%2==0)
	    {
	        cout<<-1;
	    }
	    else
	    {
	        if(n%2==0)
	        {
	        for(int i=l;i<=r;i+=2)
	        {
	            cout<<i+1<<" "<<i<<" ";
	        }
	        }
	        else
	        {
	            for(int i=l;i<=r-3;i+=2)
	            {
	                cout<<i+1<<" "<<i<<" ";
	            }
	            cout<<r-1<<" "<<r<<" "<<r-2;
	        }
	        
	    }
	    cout<<endl;
	}

}

My logic is-

  1. if L and R is even, return -1
  2. if HCF(L,R)==1, perform circular right shift on the array
  3. if HCF(L,R)!=1, perform circular tight shift and swap first and second last element

The code seems to give WA for the test case

1
15 20

When gcd(L, R) \neq 1, L is paired with R-2 in ans. But it can also be the case that gcd(L, R-2) \neq 1 as in the test case above.

thanks a lot!!