#include <bits/stdc++.h>
#pragma GCC optimize("O3", "unroll-loops")
#pragma GCC target("avx2")
long long int MOD = 1e9 + 7;
double EPS = 1e-9;
const int mxn = 100001;
using namespace std;
template <typename T>
void read(T &x) {
  cin >> x;
}
template <typename T, typename T0>
void read(T &x, T0 &y) {
  cin >> x >> y;
}
template <typename T, typename T0, typename T1>
void read(T &x, T0 &y, T1 &z) {
  cin >> x >> y >> z;
}
template <typename T, typename T0, typename T1, typename T2>
void read(T &x, T0 &y, T1 &z, T2 &w) {
  cin >> x >> y >> z >> w;
}
template <typename T>
void read(vector<T> &oneD) {
  for (long long int i = 0; i < (int)(oneD).size(); i++) {
    read(oneD[i]);
  }
}
template <typename T>
void read(T oneD[], long long int n) {
  for (long long int i = 0; i < n; i++) {
    read(oneD[i]);
  }
}
template <typename T>
void write(T &x) {
  cout << x << " ";
}
template <typename T>
void write(vector<T> &oneD) {
  for (long long int i = 0; i < (int)(oneD).size(); i++) {
    write(oneD[i]);
  }
  cout << endl;
}
template <typename T>
void write(T oneD[], int n) {
  for (long long int i = 0; i < n; i++) {
    write(oneD[i]);
  }
  cout << endl;
}
template <typename T>
inline bool umax(T &x, T y) {
  return (y > x) ? x = y, true : false;
}
template <typename T>
inline bool umin(T &x, T y) {
  return (y < x) ? x = y, true : false;
}
template <class T>
void offset(long long int o, T &x) {
  x += o;
}
template <class T>
void offset(long long int o, vector<T> &x) {
  for (auto &a : x) offset(o, a);
}
template <class T, size_t S>
void offset(long long int o, array<T, S> &x) {
  for (auto &a : x) offset(o, a);
}
template <size_t S>
string to_string(bitset<S> b) {
  string res;
  for (long long int i = (0); ((1) > 0 ? i < (S) : i > (S)); i += (1))
    res += char('0' + b[i]);
  return res;
}
string to_string(bool b) { return b ? "true" : "false"; }
inline bool isSquare(long long int x) {
  long long int s = sqrt(x);
  return (s * s == x);
}
inline bool isPowerOfTwo(long long int x) {
  return ((1LL << (long long int)log2(x)) == x);
}
template <class T>
string to_string(T v) {
  bool f = 1;
  string res;
  for (auto &x : v) {
    if (!f) {
      res += ' ';
    }
    f = 0;
    res += to_string(x);
  }
  return res;
}
template <class A>
void write(A x) {
  cout << to_string(x);
}
string to_string(const char *s) { return string(s); }
long long int minPrime[1299710];
vector<long long int> prime;
void sieve(long long int n) {
  memset(minPrime, 0, sizeof(minPrime));
  for (long long int i = 2; i * i <= n; ++i) {
    if (minPrime[i] == 0) {
      for (long long int j = i * i; j <= n; j += i) {
        if (minPrime[j] == 0) {
          minPrime[j] = i;
        }
      }
    }
  }
  for (long long int i = 2; i <= n; ++i) {
    if (minPrime[i] == 0) {
      minPrime[i] = i;
      prime.push_back(i);
    }
  }
}
vector<long long int> facts[(int)(1 * 1e6 + 10)];
void sievefact(long long int n) {
  for (long long int i = 2; i <= n; i++)
    if (facts[i].size() == 0)
      for (long long int j = i; j <= n; j += i) facts[j].push_back(i);
}
template <class H, class... T>
void write(const H &h, const T &...t) {
  write(h);
  write(t...);
}
string to_string(string s) { return s; }
vector<array<long long int, 2>> factorize(long long int x) {
  vector<array<long long int, 2>> factors;
  unordered_map<long long int, long long int> m;
  m.clear();
  while (x != 1) {
    m[minPrime[x]]++;
    x /= minPrime[x];
  }
  for (auto i : m) factors.push_back({i.first, i.second});
  return factors;
}
void print() { cout << ("\n"); }
template <class H, class... T>
void print(const H &h, const T &...t) {
  write(h);
  if (sizeof...(t)) write(' ');
  print(t...);
}
string to_string(vector<bool> v) {
  string res;
  for (long long int i = (0);
       ((1) > 0 ? i < ((int)(v).size()) : i > ((int)(v).size())); i += (1))
    res += char('0' + v[i]);
  return res;
}
string to_string(char c) { return string(1, c); }
void DBG() { cerr << "]" << endl; }
template <class H, class... T>
void DBG(H h, T... t) {
  cerr << to_string(h);
  if (sizeof...(t)) cerr << ", ";
  DBG(t...);
}
long long int extended_GCD(long long int a, long long int b, long long int &x,
                           long long int &y) {
  if (a == 0) {
    x = 0;
    y = 1;
    return b;
  }
  long long int x1, y1;
  long long int gcd = extended_GCD(b % a, a, x1, y1);
  x = y1 - (b / a) * x1;
  y = x1;
  return gcd;
}
long long int modinv(long long int a, long long int mod = MOD) {
  long long int x, y, g;
  g = extended_GCD(a, mod, x, y);
  if (g != 1)
    return -1;
  else {
    if (x < 0) x += mod;
    return x;
  }
}
long long int binpow(long long int x, long long int y, long long int p) {
  long long int res = 1;
  x = x % p;
  if (x == 0) return 0;
  while (y > 0) {
    if (y & 1) res = (res * x) % p;
    y = y >> 1;
    x = (x * x) % p;
  }
  return res;
}
bool comp(pair<long long int, long long int> a,
          pair<long long int, long long int> b) {
  return a.second < b.second;
}
void solve() {
  long long int n;
  cin >> n;
  if (n == 1) {
    cout << 1 << "\n";
    return;
  }
  if (n == 2) {
    cout << 2 << "\n";
    cout << 1 << " " << 2 << "\n";
    return;
  }
  vector<long long int> vec;
  vector<array<long long int, 2>> ans;
  for (long long int i = 1; i <= n; i++) vec.push_back(i);
  while (vec.size() > 1) {
    long long int t = vec.back();
    vec.erase(vec.end() - 1);
    long long int p = vec.back();
    if ((t + p) % 2 == 0) {
      long long int val = (t + p) / 2;
      vec.erase(vec.end() - 1);
      vec.push_back(val);
      ans.push_back({t, p});
    } else {
      long long int o = vec[vec.size() - 2];
      vec.erase(vec.end() - 2);
      long long int val = (o + t) / 2;
      vec.push_back(val);
      ans.push_back({o, t});
    }
  }
  cout << vec.front() << "\n";
  for (array<long long int, 2> array : ans) {
    cout << array[0] << " " << array[1] << "\n";
  }
  return;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long int t;
  cin >> t;
  while (t--) {
    solve();
  }
  return 0;
}

### Prompt

Your task is to create a Cpp solution to the following problem:

Numbers 1, 2, 3, ... n (each integer from 1 to n once) are written on a board. In one operation you can erase any two numbers a and b from the board and write one integer (a + b)/(2) rounded up instead.

You should perform the given operation n - 1 times and make the resulting number that will be left on the board as small as possible. 

For example, if n = 4, the following course of action is optimal:

  1. choose a = 4 and b = 2, so the new number is 3, and the whiteboard contains [1, 3, 3]; 
  2. choose a = 3 and b = 3, so the new number is 3, and the whiteboard contains [1, 3]; 
  3. choose a = 1 and b = 3, so the new number is 2, and the whiteboard contains [2]. 



It's easy to see that after n - 1 operations, there will be left only one number. Your goal is to minimize it.

Input

The first line contains one integer t (1 ≤ t ≤ 1000) — the number of test cases.

The only line of each test case contains one integer n (2 ≤ n ≤ 2 ⋅ 10^5) — the number of integers written on the board initially.

It's guaranteed that the total sum of n over test cases doesn't exceed 2 ⋅ 10^5.

Output

For each test case, in the first line, print the minimum possible number left on the board after n - 1 operations. Each of the next n - 1 lines should contain two integers — numbers a and b chosen and erased in each operation.

Example

Input


1
4


Output


2
2 4
3 3
3 1

### Response

```cpp
#include <bits/stdc++.h>
#pragma GCC optimize("O3", "unroll-loops")
#pragma GCC target("avx2")
long long int MOD = 1e9 + 7;
double EPS = 1e-9;
const int mxn = 100001;
using namespace std;
template <typename T>
void read(T &x) {
  cin >> x;
}
template <typename T, typename T0>
void read(T &x, T0 &y) {
  cin >> x >> y;
}
template <typename T, typename T0, typename T1>
void read(T &x, T0 &y, T1 &z) {
  cin >> x >> y >> z;
}
template <typename T, typename T0, typename T1, typename T2>
void read(T &x, T0 &y, T1 &z, T2 &w) {
  cin >> x >> y >> z >> w;
}
template <typename T>
void read(vector<T> &oneD) {
  for (long long int i = 0; i < (int)(oneD).size(); i++) {
    read(oneD[i]);
  }
}
template <typename T>
void read(T oneD[], long long int n) {
  for (long long int i = 0; i < n; i++) {
    read(oneD[i]);
  }
}
template <typename T>
void write(T &x) {
  cout << x << " ";
}
template <typename T>
void write(vector<T> &oneD) {
  for (long long int i = 0; i < (int)(oneD).size(); i++) {
    write(oneD[i]);
  }
  cout << endl;
}
template <typename T>
void write(T oneD[], int n) {
  for (long long int i = 0; i < n; i++) {
    write(oneD[i]);
  }
  cout << endl;
}
template <typename T>
inline bool umax(T &x, T y) {
  return (y > x) ? x = y, true : false;
}
template <typename T>
inline bool umin(T &x, T y) {
  return (y < x) ? x = y, true : false;
}
template <class T>
void offset(long long int o, T &x) {
  x += o;
}
template <class T>
void offset(long long int o, vector<T> &x) {
  for (auto &a : x) offset(o, a);
}
template <class T, size_t S>
void offset(long long int o, array<T, S> &x) {
  for (auto &a : x) offset(o, a);
}
template <size_t S>
string to_string(bitset<S> b) {
  string res;
  for (long long int i = (0); ((1) > 0 ? i < (S) : i > (S)); i += (1))
    res += char('0' + b[i]);
  return res;
}
string to_string(bool b) { return b ? "true" : "false"; }
inline bool isSquare(long long int x) {
  long long int s = sqrt(x);
  return (s * s == x);
}
inline bool isPowerOfTwo(long long int x) {
  return ((1LL << (long long int)log2(x)) == x);
}
template <class T>
string to_string(T v) {
  bool f = 1;
  string res;
  for (auto &x : v) {
    if (!f) {
      res += ' ';
    }
    f = 0;
    res += to_string(x);
  }
  return res;
}
template <class A>
void write(A x) {
  cout << to_string(x);
}
string to_string(const char *s) { return string(s); }
long long int minPrime[1299710];
vector<long long int> prime;
void sieve(long long int n) {
  memset(minPrime, 0, sizeof(minPrime));
  for (long long int i = 2; i * i <= n; ++i) {
    if (minPrime[i] == 0) {
      for (long long int j = i * i; j <= n; j += i) {
        if (minPrime[j] == 0) {
          minPrime[j] = i;
        }
      }
    }
  }
  for (long long int i = 2; i <= n; ++i) {
    if (minPrime[i] == 0) {
      minPrime[i] = i;
      prime.push_back(i);
    }
  }
}
vector<long long int> facts[(int)(1 * 1e6 + 10)];
void sievefact(long long int n) {
  for (long long int i = 2; i <= n; i++)
    if (facts[i].size() == 0)
      for (long long int j = i; j <= n; j += i) facts[j].push_back(i);
}
template <class H, class... T>
void write(const H &h, const T &...t) {
  write(h);
  write(t...);
}
string to_string(string s) { return s; }
vector<array<long long int, 2>> factorize(long long int x) {
  vector<array<long long int, 2>> factors;
  unordered_map<long long int, long long int> m;
  m.clear();
  while (x != 1) {
    m[minPrime[x]]++;
    x /= minPrime[x];
  }
  for (auto i : m) factors.push_back({i.first, i.second});
  return factors;
}
void print() { cout << ("\n"); }
template <class H, class... T>
void print(const H &h, const T &...t) {
  write(h);
  if (sizeof...(t)) write(' ');
  print(t...);
}
string to_string(vector<bool> v) {
  string res;
  for (long long int i = (0);
       ((1) > 0 ? i < ((int)(v).size()) : i > ((int)(v).size())); i += (1))
    res += char('0' + v[i]);
  return res;
}
string to_string(char c) { return string(1, c); }
void DBG() { cerr << "]" << endl; }
template <class H, class... T>
void DBG(H h, T... t) {
  cerr << to_string(h);
  if (sizeof...(t)) cerr << ", ";
  DBG(t...);
}
long long int extended_GCD(long long int a, long long int b, long long int &x,
                           long long int &y) {
  if (a == 0) {
    x = 0;
    y = 1;
    return b;
  }
  long long int x1, y1;
  long long int gcd = extended_GCD(b % a, a, x1, y1);
  x = y1 - (b / a) * x1;
  y = x1;
  return gcd;
}
long long int modinv(long long int a, long long int mod = MOD) {
  long long int x, y, g;
  g = extended_GCD(a, mod, x, y);
  if (g != 1)
    return -1;
  else {
    if (x < 0) x += mod;
    return x;
  }
}
long long int binpow(long long int x, long long int y, long long int p) {
  long long int res = 1;
  x = x % p;
  if (x == 0) return 0;
  while (y > 0) {
    if (y & 1) res = (res * x) % p;
    y = y >> 1;
    x = (x * x) % p;
  }
  return res;
}
bool comp(pair<long long int, long long int> a,
          pair<long long int, long long int> b) {
  return a.second < b.second;
}
void solve() {
  long long int n;
  cin >> n;
  if (n == 1) {
    cout << 1 << "\n";
    return;
  }
  if (n == 2) {
    cout << 2 << "\n";
    cout << 1 << " " << 2 << "\n";
    return;
  }
  vector<long long int> vec;
  vector<array<long long int, 2>> ans;
  for (long long int i = 1; i <= n; i++) vec.push_back(i);
  while (vec.size() > 1) {
    long long int t = vec.back();
    vec.erase(vec.end() - 1);
    long long int p = vec.back();
    if ((t + p) % 2 == 0) {
      long long int val = (t + p) / 2;
      vec.erase(vec.end() - 1);
      vec.push_back(val);
      ans.push_back({t, p});
    } else {
      long long int o = vec[vec.size() - 2];
      vec.erase(vec.end() - 2);
      long long int val = (o + t) / 2;
      vec.push_back(val);
      ans.push_back({o, t});
    }
  }
  cout << vec.front() << "\n";
  for (array<long long int, 2> array : ans) {
    cout << array[0] << " " << array[1] << "\n";
  }
  return;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long int t;
  cin >> t;
  while (t--) {
    solve();
  }
  return 0;
}

```