#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int t;
  cin >> t;
  while (t--) {
    long long int n;
    cin >> n;
    char a[n][n];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        if (i == 0 && j == 0) {
          a[i][j] = 'S';
        } else if (i == (n - 1) && j == (n - 1)) {
          a[i][j] = 'F';
        } else {
          a[i][j] = '0';
        }
      }
    }
    int x;
    if (a[0][1] == a[1][0]) {
      x = a[0][1];
      if (x == 0) {
        a[0][1] = 1;
        a[1][0] = 1;
        cout << 2 << endl;
        cout << 1 << 2 << endl;
        cout << 2 << 1 << endl;
      } else {
        a[0][1] = 0;
        a[1][0] = 0;
        cout << 2 << endl;
        cout << 1 << 2 << endl;
        cout << 2 << 1 << endl;
      }
    }
  }
}
