#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0), cin.tie(0);
  ;
  int64_t Tc;
  cin >> Tc;
  while (Tc--) {
    int64_t a;
    cin >> a;
    if (a == 1)
      cout << "1\n";
    else if (a == 2)
      cout << "2\n1 2\n";
    else {
      cout << 2 << "\n";
      cout << a << " " << a - 2 << "\n";
      cout << a - 1 << " " << a - 1 << "\n";
      int64_t tmp = a - 1;
      for (int64_t i = 2; i < a - 1; ++i) {
        cout << tmp << " " << tmp - 2 << "\n";
        tmp--;
      }
    }
  }
}
