#include <bits/stdc++.h>
using namespace std;
int sum(vector<long long> arr, int x, int s) {
  long long size = arr.size();
  int l = s + 1, r = size - 1;
  int ans = 0;
  while (l <= r) {
    int mid = (l + r) / 2;
    if (arr[mid] > x)
      r = mid - 1;
    else if (arr[mid] < x) {
      l = mid + 1;
      ans = mid;
    } else {
      return mid;
    }
  }
  return ans;
}
void solve1() {
  long long n;
  cin >> n;
  cout << 2 << endl;
  cout << n << " " << (n - 1) << endl;
  int prev = round((2 * n - 1) / 2.00);
  for (int i = n - 2; i > 0; i--) {
    cout << i << " " << prev << endl;
    prev = round((i + prev) / 2.00);
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long t;
  cin >> t;
  for (long long i = 0; i < t; i++) {
    solve1();
  }
  return 0;
}
