#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, t, m;
  cin >> t;
  while (t--) {
    cin >> n;
    cout << 2 << endl;
    int count = 0;
    int arr[n + 1];
    stack<int> s;
    for (int i = 1; i <= n; i++) {
      s.push(i);
    }
    while (s.size() > 1) {
      double val = s.top();
      cout << s.top() << " ";
      s.pop();
      val += s.top();
      cout << s.top() << endl;
      s.pop();
      val = round(val / 2);
      s.push(val);
    }
  }
  return 0;
}
