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