#include <bits/stdc++.h>
using namespace std;
const int INF = INT_MAX;
const long long MOD = 1e9 + 7;
const long long MOD_2 = 998244353;
ifstream fin("test1.txt");
void solve() {
  int n;
  cin >> n;
  cout << 2 << endl;
  if (n == 2) {
    cout << 1 << " " << 2 << endl;
    return;
  }
  cout << n << " " << n - 2 << endl;
  cout << n - 1 << " " << n - 1 << endl;
  n--;
  int mem = n;
  for (int i = 0; i < (mem - 2); i++) {
    cout << n << " " << n - 2 << endl;
    n--;
  }
}
int main() {
  int t;
  cin >> t;
  while (t--) solve();
}
