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