#include <bits/stdc++.h>
using namespace std;
void solve() {
  long long int n;
  cin >> n;
  cout << 2 << endl;
  cout << n << " " << n - 1 << endl;
  for (int i = n - 2; i > 0; i--) cout << i << " " << i + 2 << endl;
}
int main() {
  int t;
  cin >> t;
  while (t--) {
    solve();
    cout << endl;
  }
}
