#include <bits/stdc++.h>
using namespace std;
int prime[1000005];
void sieve() {
  prime[0] = prime[1] = 1;
  for (int i = 4; i <= 1000005; i += 2) prime[i] = 2;
  for (long long i = 3; i * i <= 1000005; i += 2) {
    if (prime[i] == 0) {
      for (long long j = i * i; j <= 1000005; j += i * 2) prime[j] = i;
    }
  }
}
bool is_prime(long long x) {
  int ok = 1;
  for (int i = 2; i * i <= x; i++) {
    if (x % i == 0) {
      ok = -1;
      break;
    }
  }
  return ok;
}
void solve() {
  long long n;
  cin >> n;
  if (n == 2) {
    cout << "2\n" << n << " " << n - 1 << "\n";
    return;
  }
  cout << "2\n";
  cout << n << " " << n - 1 << "\n" << n << " " << n - 2 << "\n";
  long long c1 = n - 1, c2 = n - 3;
  for (int i = 0; i < n - 3; i++) {
    cout << c1 << " " << c2 << "\n";
    c1--, c2--;
  }
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  int t = 1;
  cin >> t;
  while (t--) solve();
}
