#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
const int INF = 1000000007;
int main() {
  int TESTCASE;
  cin >> TESTCASE;
  while (TESTCASE--) {
    int n;
    cin >> n;
    cout << 2 << endl;
    int prev = n;
    for (int i = n; i > 1; i--) {
      cout << prev << " " << i - 1 << endl;
      prev = ceil(((double)prev + i - 1) / 2);
    }
  }
}
