#include <bits/stdc++.h>
using namespace std;
long long n, t, a;
int main() {
  cin >> t;
  while (t--) {
    cin >> n;
    a = n;
    cout << 2 << endl;
    cout << a << ' ' << a - 1 << endl;
    for (int i = 0; i < n - 2; i++) {
      cout << a << ' ' << a - 2 << endl;
      a--;
    }
  }
}
