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