#include <bits/stdc++.h>
using namespace std;
void solve() {
  long long n;
  cin >> n;
  long long cur = n;
  cout << 2 << "\n";
  for (long long i = n - 1; i >= 1; i--) {
    cout << cur << " " << i << "\n";
    if ((cur + i) % 2)
      cur = 1 + (cur + i) / 2;
    else
      cur = (cur + i) / 2;
  }
}
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long t = 1;
  cin >> t;
  cout << fixed << setprecision(12);
  while (t--) {
    solve();
  }
  cerr << "Time Taken : " << (float)clock() / CLOCKS_PER_SEC << " secs"
       << "\n";
}
