def pair(n): if n%2 == 0: return "No" l = (3/2)*(n+1) res = [] for i in range(1, (n+1)//2): res.append((i, l+i-1)) for i in range(1, (n+1)//2+n%2): res.append((n-i+1, l-i)) return "Yes\n"+"\n".join([f"{int(a[0])} {int(a[1])}" for a in res]) for _ in range(int(input())): print(pair(int(input())))