#include <bits/stdc++.h>
using namespace std;
int main() {
  int t, n;
  cin >> t;
  while (t--) {
    cin >> n;
    cout << "2\n";
    int a = n, b = n - 1;
    for (int i = 1; i < n; i++) {
      cout << a << " " << b << endl;
      a = (a + b) / 2 + ((a + b) % 2 != 0);
      b--;
    }
  }
}
