#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
const long long N = 1000005;
void solve() {
  long long n;
  cin >> n;
  cout << 2 << "\n";
  long long k = n, p = n - 1;
  cout << p << " " << k << "\n";
  p--;
  for (long long i = 0; i < n - 2; i++) {
    cout << p << " " << k << "\n";
    k--;
    p--;
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t;
  cin >> t;
  while (t--) solve();
}
