#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    cout << 2 << '\n';
    bool first = true;
    double div = 0;
    for (int i = n; i > 1; i--) {
      if (first) {
        cout << i << " " << i - 1 << '\n';
        div = ceil((i + (i - 1)) / 2.0);
        first = false;
      } else {
        cout << (int)div << " " << (i - 1) << '\n';
        div = ceil((i + (i - 1)) / 2.0);
      }
    }
  }
  return 0;
}
