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

void solve()
{
    int n;
    cin >> n;
    
    int ans = n/2 + n % 2;
    
    int i = 1, j = 3*n;
    int cnt = ans;
    
    cout << ans << endl;
    
    while(cnt --)
    {
        cout << i << " " << j << endl;
        i += 3;
        j -= 3;
    }
}

int main() {
    // your code goes here
    int t;
    cin >> t;
    
    while(t--)
        solve();
        
}