等差数列求和可以推导出 $s$ 数列的所有的值,其中 $s_1 = 3(n + 1)/2$,因此 $n$ 只能是奇数。构造解的思路在上面题解的评论区,先构造出和相等的数对,前 $n$ 个数字正序排列,后 $n$ 个数字倒序排列。设 $s$ 数组正中间的值是 $d$,那么只需要交换一些数字构造出 $d+0, d+1, d-1, d+2, d-2, \dots$,奇数增量嵌套构造即可,偶数同理。

//  2023/11/19

#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <climits>

#include <iostream>
#include <iomanip>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <utility>
#include <functional>

using namespace std;

const int INF = 0x3f3f3f3f, MOD = 1e9 + 7;
const double eps = 1e-8;
const int dir[8][2] = {
{0, 1}, {0, -1},
{1, 0}, {-1, 0},
{1, 1}, {1, -1},
{-1, 1}, {-1, -1},
};

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> VI;
typedef pair<int, int> PII;

const ull Pr = 131;

#define LN ListNode
#define LNP ListNode*
#define TN TreeNode
#define TNP TreeNode*

#define For(i, a, b) for (int i = int(a); i < int(b); ++i)
#define Rof(i, a, b) for (int i = int(b) - 1; i >= int(a); --i)
#define For1(i, a, b) for (int i = int(a); i <= int(b); ++i)
#define Rof1(i, a, b) for (int i = int(b); i >= int(a); --i)
#define ForE(i, j) for (int i = h[j]; i != -1; i = ne[i])

#define f1 first
#define f2 second
#define pb push_back
#define has(a, x) (a.find(x) != a.end())
#define nonempty(a) (!a.empty())
#define all(a) (a).begin(),(a).end()
#define SZ(a) int((a).size())

#ifdef DEBUG
#define debug1(x) cout << #x" = " << x << endl;
#define debug2(x,y) cout << #x" = " << x << " "#y" = " << y << endl;
#define debug3(x,y,z) cout << #x" = " << x << " "#y" = " << y << " "#z" = " << z << endl;
#else
#define debug1
#define debug2
#define debug3
#endif

#ifdef DEBUG

struct ListNode {
    int val;
    ListNode *next;
    ListNode() : val(0), next(nullptr) {}
    ListNode(int val) : val(val), next(nullptr) {}
    ListNode(int val, ListNode *next) : val(val), next(next) {}
};

struct TreeNode {
    int val;
    TreeNode *left;
    TreeNode *right;
    TreeNode() : val(0), left(nullptr), right(nullptr) {}
    TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}
    TreeNode(int x, TreeNode *left, TreeNode *right) : val(x), left(left), right(right) {}
};

#endif

const int N = 200010;
int t, n;
PII a[N];

int main(int argc, const char * argv[]) {
    #ifdef USE_INPUT_FILE
    freopen("input.txt", "r", stdin);
    #endif

    std::ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

    cin >> t;
    while (t--) {
        cin >> n;
        
        if (n % 2 == 0) {
            cout << "NO\n";
            continue;
        }
        
        if (n == 1) {
            cout << "YES\n1 2\n";
            continue;
        }
        
        For1(i, 1, n) {
            a[i].f1 = 2 * n + 1 - i;
            a[i].f2 = i;
        }
        
        int top = (n - 1) / 2;
        int l = 1, r = 1 + top;
        while (l < r) {
            swap(a[l].f2, a[r].f2);
            l++; r--;
        }
        
        l = top + 2, r = n;
        while (l < r) {
            swap(a[l].f2, a[r].f2);
            l++; r--;
        }
        
        cout << "YES\n";
        For1(i, 1, n) {
            cout << a[i].f1 << ' ' << a[i].f2 << '\n';
        }
    }

    return 0;
}