#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
long long mcm(long long a, long long b) { return (a * b) / gcd(a, b); }
bool comp(long long a, long long b) { return a > b; }
void solve() {
  int n;
  cin >> n;
  vector<int> a(n + 1);
  for (int i = 1; i <= n; i++) {
    a[i] = i;
  }
  cout << "2\n";
  for (int i = n; i > 1; i--) {
    cout << a[i] << " " << a[i - 1] << "\n";
    a[i - 1] = (a[i] + a[i - 1] + 1) / 2;
  }
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ofstream fout("test.out");
  ifstream fin("test.in");
  long long t = 1;
  cin >> t;
  while (t--) solve();
  return 0;
}
