#include <bits/stdc++.h>
using namespace std;
void solve() {
  long long n;
  cin >> n;
  cout << 2 << "\n";
  int x = n, y = n - 1;
  for (int i = 1; i < n; i++) {
    cout << x << " " << y << "\n";
    x = (x + y + 1) / 2;
    y--;
  }
  return;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int t;
  cin >> t;
  while (t--) {
    solve();
    cout << endl;
  }
  return 0;
}
