#include <bits/stdc++.h>
using namespace std;
const long long int mod = 1e9 + 7;
void go() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
}
const long long int N = 2e5 + 2;
struct node {
  int val;
  int a, b, c;
  node() { val = a = b = c = 0; }
  node(int val1, int a1, int b1, int c1) {
    val = val1;
    a = a1 = b = b1;
    c = c1;
  }
};
bool operator<(node a, node b) { return a.val < b.val; }
int main() {
  go();
  long long int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    priority_queue<int> odd, even;
    vector<pair<long long int, long long int> > ans;
    int a = n;
    int b = n - 1;
    cout << 2 << endl;
    cout << a << " " << b << endl;
    b--;
    for (int i = 1; i <= n - 2; i++) {
      cout << a << " " << b << endl;
      a--;
      b--;
    }
  }
  return 0;
}
