#include <bits/stdc++.h>
using namespace std;
template <typename T>
void print_vec_1d(vector<T> x, string name) {
  cout << name << endl;
  cout << "[ ";
  for (int i = 0; i < x.size(); i++) {
    cout << x[i];
    if (i != x.size() - 1)
      cout << ", ";
    else
      cout << " ]" << endl;
  }
}
template <typename T>
void print_vec_2d(vector<vector<T>> x, string name) {
  cout << name << endl;
  cout << "[ ";
  for (int i = 0; i < x.size(); i++) {
    cout << "[ ";
    for (int j = 0; j < x[i].size(); j++) {
      cout << x[i][j];
      if (j != x[i].size() - 1)
        cout << ", ";
      else {
        cout << " ]";
        if (!((i == x.size() - 1) && (j == x[i].size() - 1))) {
          cout << "," << endl;
        }
      }
    }
  }
  cout << " ]" << endl;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int t;
  cin >> t;
  for (int i = 0; i < t; i++) {
    int n;
    cin >> n;
    cout << 2 << "\n";
    if (n == 2) {
      cout << 1 << " " << 2 << "\n";
    } else {
      cout << n - 2 << " " << n << "\n";
      cout << n - 1 << " " << n - 1 << "\n";
      for (int j = 0; j < n - 3; j++) {
        cout << n - 3 - j << " " << n - 1 - j << "\n";
      }
    }
  }
}
