#include <bits/stdc++.h>
using namespace std;
bool isPrime(long long int n) {
  for (long long int i = 2; i * i <= n; i++) {
    if (n % i == 0) return false;
  }
  return true;
}
int main() {
  long long int t;
  cin >> t;
  long long int temp, n, m, i, j, a, b, c, k;
  string s;
  bool flag;
  unordered_map<long long int, long long int> mapp;
  vector<long long int> vec, nums;
  flag = true;
  while (t--) {
    long long int count = 0;
    cin >> n;
    cout << 2 << endl;
    a = n, b = n - 1;
    while (n > 1) {
      cout << a << " " << b << endl;
      if (a + b % 2 == 0) {
        a = (a + b) / 2;
      } else {
        a = (a + b + 1) / 2;
      }
      b--;
      n--;
    }
    nums.clear();
    vec.clear();
    mapp.clear();
  }
  return 0;
}
