#include <bits/stdc++.h>
using namespace std;
const double PI = acos(-1);
const long long MOD = 1e9 + 7;
const long long INF = LONG_LONG_MAX;
const long long MINF = LONG_LONG_MIN;
const int N = 3e5 + 5;
template <typename T>
inline T abs(T x) {
  return x < 0 ? -x : x;
}
inline long long pow_mod(long long x, long long n) {
  long long r = 1;
  while (n) {
    if (n & 1) r = (r * x) % MOD;
    x = (x * x) % MOD;
    n >>= 1;
  }
  return r;
}
inline long long pow_(long long x, long long n) {
  long long r = 1;
  while (n) {
    if (n & 1) r = (r * x);
    x = (x * x);
    n >>= 1;
  }
  return r;
}
inline void solve() {
  int n;
  scanf("%d", &n);
  printf("%d\n", 2);
  if (n == 2) {
    printf("%d %d\n", 1, 2);
    return;
  }
  printf("%d %d\n", n, n - 2);
  printf("%d %d\n", n - 1, n - 1);
  for (int i = n - 1; i >= 3; --i) printf("%d %d\n", i, i - 2);
}
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int t = 1;
  scanf("%d", &t);
  while (t--) solve();
}
