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