#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = LLONG_MAX;
const long double PI = 3.141592653589793238463;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long T;
  cin >> T;
  while (T--) {
    long long n;
    cin >> n;
    cout << 2 << "\n";
    long long a = n;
    for (long long i = n - 1; i >= (long long)1; i--) {
      long long b = i;
      cout << a << " " << b << "\n";
      if ((a + b) % 2 == 1)
        a = (a + b) / 2 + 1;
      else
        a = (a + b) / 2;
    }
  }
  return 0;
}
