#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    cout << 2 << endl;
    if (n == 2) {
      cout << 1 << " " << 2 << endl;
      continue;
    }
    cout << n - 2 << " " << n << endl;
    cout << n - 1 << " " << n - 1 << endl;
    int i = n - 3, j = n - 1;
    while (i) {
      cout << i << " " << j << endl;
      i--;
      j--;
    }
  }
  return 0;
}
