#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int t, n, i, x;
  cin >> t;
  while (t--) {
    cin >> n;
    i = n - 1;
    x = n;
    cout << "2" << endl;
    while (i != 0) {
      cout << i << " " << x << endl;
      x = ceil((i + x) / 2.0);
      i--;
    }
  }
  return 0;
}
