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