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