#include <bits/stdc++.h>
using namespace std;
int main() {
  long long t;
  cin >> t;
  while (t--) {
    long long k, n;
    cin >> n;
    cout << 2 << endl;
    if (n == 2)
      cout << 1 << " " << 2 << endl;
    else {
      cout << n - 2 << " " << n << endl;
      long long l = (n - 2 + n) / 2;
      for (int i = n - 1; i >= 1; i--) {
        if (i == n - 2) continue;
        cout << i << " " << l << endl;
        l = (i + l) / 2;
      }
    }
  }
}
