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