#include <bits/stdc++.h>
using namespace std;
long long t, n;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> t;
  while (t--) {
    cin >> n;
    cout << "2\n";
    if (n == 2) {
      cout << "1 2\n";
      continue;
    }
    cout << n << " " << n - 2 << "\n";
    cout << n - 1 << " " << n - 1 << "\n";
    for (int i = n - 1; i >= 3; i--) {
      cout << i << " " << i - 2 << "\n";
    }
  }
  return 0;
}
