#include <bits/stdc++.h>
using namespace std;
class IO {
  static const int bufSize = 1 << 18;
  char inBuf[bufSize], outBuf[bufSize];
  char *ip1 = inBuf, *ip2 = inBuf;
  int ok = 1, op1 = -1, op2 = bufSize - 1;
  template <typename T>
  __inline__ __attribute__((always_inline)) void __RI(T& x) {
    int ch = gc(), neg = 1;
    x = 0;
    for (; !(ch == EOF || isdigit(ch) || ch == '-'); ch = gc())
      ;
    if (ch == EOF) {
      ok = 0;
      return;
    }
    if (ch == '-') neg = -1, ch = gc();
    for (; isdigit(ch); ch = gc()) x = x * 10 + (ch - 48) * neg;
  }
  template <typename T>
  __inline__ __attribute__((always_inline)) void __RC(T& x) {
    unsigned char ch;
    while (isspace(ch = gc()))
      ;
    if (ch == EOF) {
      ok = 0;
      return;
    }
    x = ch;
  }
  __inline__ __attribute__((always_inline)) void __RS(string& x) {
    char ch;
    x.clear();
    for (ch = gc(); isspace(ch); ch = gc())
      ;
    if (ch == EOF) {
      ok = 0;
      return;
    }
    for (; !isspace(ch); ch = gc()) x.push_back(ch);
  }

 public:
  __inline__ __attribute__((always_inline)) int gc() {
    return ip1 == ip2 && (ip2 = (ip1 = inBuf) + fread(inBuf, 1, bufSize, stdin),
                          ip1 == ip2)
               ? EOF
               : *ip1++;
  }
  __inline__ __attribute__((always_inline)) IO& R(char& x) {
    __RC(x);
    return *this;
  }
  __inline__ __attribute__((always_inline)) IO& R(unsigned char& x) {
    __RC(x);
    return *this;
  }
  __inline__ __attribute__((always_inline)) IO& R(string& x) {
    __RS(x);
    return *this;
  }
  template <typename T1, typename T2>
  __inline__ __attribute__((always_inline)) IO& R(pair<T1, T2>& x) {
    R(x.first), R(x.second);
    return *this;
  }
  template <typename T>
  __inline__ __attribute__((always_inline)) IO& R(vector<T>& x) {
    for (auto& i : x) R(i);
    return *this;
  }
  template <typename T, typename... Args>
  __inline__ __attribute__((always_inline)) IO& RA(T* a, int n) {
    for (int i = 0; i < n; ++i) R(a[i]);
    return *this;
  }
  template <typename T, typename... Args>
  __inline__ __attribute__((always_inline)) IO& R(T& x, Args&... args) {
    R(x), R(args...);
    return *this;
  }
  template <typename T, typename... Args>
  __inline__ __attribute__((always_inline)) IO& RA(T* a, int n, Args... args) {
    for (int i = 0; i < n; ++i) RA(a[i], args...);
    return *this;
  }
  template <typename T>
  __inline__ __attribute__((always_inline)) IO& R(T& x) {
    static_assert(is_integral<T>::value, "Unsupported types");
    if (is_integral<T>::value) __RI(x);
    return *this;
  }

 private:
  char space = ' ';
  template <typename T>
  __inline__ __attribute__((always_inline)) void __WI(T x) {
    static char buf[64];
    static int len = -1;
    if (x >= 0) {
      do {
        buf[++len] = x % 10 + 48, x /= 10;
      } while (x);
    } else {
      pc('-');
      do {
        buf[++len] = -(x % 10) + 48, x /= 10;
      } while (x);
    }
    while (len >= 0) {
      pc(buf[len]), --len;
    }
  }

 public:
  __inline__ __attribute__((always_inline)) void pc(const char& x) {
    if (op1 == op2) flush();
    outBuf[++op1] = x;
  }
  __inline__ __attribute__((always_inline)) void flush() {
    fwrite(outBuf, 1, op1 + 1, stdout), op1 = -1;
  }
  __inline__ __attribute__((always_inline)) IO& W(const char& x) {
    pc(x);
    return *this;
  }
  __inline__ __attribute__((always_inline)) IO& W(const char* x) {
    while (*x != '\0') pc(*(x++));
    return *this;
  }
  __inline__ __attribute__((always_inline)) IO& W(const string& x) {
    W(x.c_str());
    return *this;
  }
  template <typename T>
  __inline__ __attribute__((always_inline)) IO& W(const vector<T>& x) {
    for (auto& i : x) WS(i);
    WL();
    return *this;
  }
  __inline__ __attribute__((always_inline)) IO& WL() {
    W('\n');
    return *this;
  }
  template <typename T1, typename T2>
  __inline__ __attribute__((always_inline)) IO& W(const pair<T1, T2>& x) {
    WS(x.first), W(x.second);
    return *this;
  }
  template <typename T>
  __inline__ __attribute__((always_inline)) IO& WL(const T& x) {
    W(x), W('\n');
    return *this;
  }
  __inline__ __attribute__((always_inline)) IO& WS() {
    W(' ');
    return *this;
  }
  template <typename T>
  __inline__ __attribute__((always_inline)) IO& WS(const T& x) {
    W(x), W(space);
    return *this;
  }
  template <typename T>
  __inline__ __attribute__((always_inline)) IO& WA(T* a, int n) {
    for (int i = 0; i < n; i++) WS(a[i]);
    WL();
    return *this;
  }
  template <typename T, typename... Args>
  __inline__ __attribute__((always_inline)) IO& W(const T& x,
                                                  const Args&... args) {
    W(x), W(space), W(args...);
    return *this;
  }
  template <typename... Args>
  __inline__ __attribute__((always_inline)) IO& WL(const Args&... args) {
    W(args...), W('\n');
    return *this;
  }
  template <typename T, typename... Args>
  __inline__ __attribute__((always_inline)) IO& WA(T* a, int n, Args... args) {
    for (int i = 0; i < n; i++) WA(a[i], args...);
    return *this;
  }
  template <typename T>
  __inline__ __attribute__((always_inline)) IO& W(const T& x) {
    static_assert(is_integral<T>::value, "Unsupported types");
    if (is_integral<T>::value) __WI(x);
    return *this;
  }
  template <typename T>
  __inline__ __attribute__((always_inline)) IO& operator>>(T& x) {
    R(x);
    return *this;
  }
  template <typename T>
  __inline__ __attribute__((always_inline)) IO& operator<<(const T& x) {
    W(x);
    return *this;
  }
  bool good() { return ok; }
  IO() {}
  ~IO() { flush(); }
} io;
const int32_t INF = 0x3f3f3f3f;
const int64_t INFL = 0x3f3f3f3f3f3f3f3fLL;
void solve() {
  int n;
  io >> n;
  priority_queue<int> q[2];
  for (int i = 1; i <= n; i++) q[i & 1].push(i);
  vector<pair<int, int>> ans;
  while (q[0].size() > 1 || q[1].size() > 1) {
    if (q[0].size() > 1 && q[1].size() > 1) {
      int x = q[0].top();
      q[0].pop();
      int y = q[0].top();
      int u = q[1].top();
      q[1].pop();
      int v = q[1].top();
      if (x + y > u + v) {
        q[0].pop();
        q[1].push(u);
        ans.emplace_back(x, y);
        int t = (x + y + 1) / 2;
        q[t & 1].push(t);
      } else {
        q[1].pop();
        q[0].push(x);
        ans.emplace_back(u, v);
        int t = (u + v + 1) / 2;
        q[t & 1].push(t);
      }
    } else if (q[0].size() > 1) {
      int x = q[0].top();
      q[0].pop();
      int y = q[0].top();
      q[0].pop();
      ans.emplace_back(x, y);
      int t = (x + y + 1) / 2;
      q[t & 1].push(t);
    } else {
      int u = q[1].top();
      q[1].pop();
      int v = q[1].top();
      q[1].pop();
      ans.emplace_back(u, v);
      int t = (u + v + 1) / 2;
      q[t & 1].push(t);
    }
  }
  if (q[0].size() + q[1].size() == 2) {
    int x = q[0].top();
    q[0].pop();
    int y = q[1].top();
    q[1].pop();
    ans.emplace_back(x, y);
    int z = (x + y + 1) / 2;
    q[z & 1].push(z);
  }
  if (q[0].size() == 1)
    io.WL(q[0].top());
  else
    io.WL(q[1].top());
  for (auto [x, y] : ans) {
    io.WL(x, y);
  }
}
int main() {
  int T;
  io >> T;
  while (T--) solve();
  return 0;
}

### Prompt

Please formulate 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>
using namespace std;
class IO {
  static const int bufSize = 1 << 18;
  char inBuf[bufSize], outBuf[bufSize];
  char *ip1 = inBuf, *ip2 = inBuf;
  int ok = 1, op1 = -1, op2 = bufSize - 1;
  template <typename T>
  __inline__ __attribute__((always_inline)) void __RI(T& x) {
    int ch = gc(), neg = 1;
    x = 0;
    for (; !(ch == EOF || isdigit(ch) || ch == '-'); ch = gc())
      ;
    if (ch == EOF) {
      ok = 0;
      return;
    }
    if (ch == '-') neg = -1, ch = gc();
    for (; isdigit(ch); ch = gc()) x = x * 10 + (ch - 48) * neg;
  }
  template <typename T>
  __inline__ __attribute__((always_inline)) void __RC(T& x) {
    unsigned char ch;
    while (isspace(ch = gc()))
      ;
    if (ch == EOF) {
      ok = 0;
      return;
    }
    x = ch;
  }
  __inline__ __attribute__((always_inline)) void __RS(string& x) {
    char ch;
    x.clear();
    for (ch = gc(); isspace(ch); ch = gc())
      ;
    if (ch == EOF) {
      ok = 0;
      return;
    }
    for (; !isspace(ch); ch = gc()) x.push_back(ch);
  }

 public:
  __inline__ __attribute__((always_inline)) int gc() {
    return ip1 == ip2 && (ip2 = (ip1 = inBuf) + fread(inBuf, 1, bufSize, stdin),
                          ip1 == ip2)
               ? EOF
               : *ip1++;
  }
  __inline__ __attribute__((always_inline)) IO& R(char& x) {
    __RC(x);
    return *this;
  }
  __inline__ __attribute__((always_inline)) IO& R(unsigned char& x) {
    __RC(x);
    return *this;
  }
  __inline__ __attribute__((always_inline)) IO& R(string& x) {
    __RS(x);
    return *this;
  }
  template <typename T1, typename T2>
  __inline__ __attribute__((always_inline)) IO& R(pair<T1, T2>& x) {
    R(x.first), R(x.second);
    return *this;
  }
  template <typename T>
  __inline__ __attribute__((always_inline)) IO& R(vector<T>& x) {
    for (auto& i : x) R(i);
    return *this;
  }
  template <typename T, typename... Args>
  __inline__ __attribute__((always_inline)) IO& RA(T* a, int n) {
    for (int i = 0; i < n; ++i) R(a[i]);
    return *this;
  }
  template <typename T, typename... Args>
  __inline__ __attribute__((always_inline)) IO& R(T& x, Args&... args) {
    R(x), R(args...);
    return *this;
  }
  template <typename T, typename... Args>
  __inline__ __attribute__((always_inline)) IO& RA(T* a, int n, Args... args) {
    for (int i = 0; i < n; ++i) RA(a[i], args...);
    return *this;
  }
  template <typename T>
  __inline__ __attribute__((always_inline)) IO& R(T& x) {
    static_assert(is_integral<T>::value, "Unsupported types");
    if (is_integral<T>::value) __RI(x);
    return *this;
  }

 private:
  char space = ' ';
  template <typename T>
  __inline__ __attribute__((always_inline)) void __WI(T x) {
    static char buf[64];
    static int len = -1;
    if (x >= 0) {
      do {
        buf[++len] = x % 10 + 48, x /= 10;
      } while (x);
    } else {
      pc('-');
      do {
        buf[++len] = -(x % 10) + 48, x /= 10;
      } while (x);
    }
    while (len >= 0) {
      pc(buf[len]), --len;
    }
  }

 public:
  __inline__ __attribute__((always_inline)) void pc(const char& x) {
    if (op1 == op2) flush();
    outBuf[++op1] = x;
  }
  __inline__ __attribute__((always_inline)) void flush() {
    fwrite(outBuf, 1, op1 + 1, stdout), op1 = -1;
  }
  __inline__ __attribute__((always_inline)) IO& W(const char& x) {
    pc(x);
    return *this;
  }
  __inline__ __attribute__((always_inline)) IO& W(const char* x) {
    while (*x != '\0') pc(*(x++));
    return *this;
  }
  __inline__ __attribute__((always_inline)) IO& W(const string& x) {
    W(x.c_str());
    return *this;
  }
  template <typename T>
  __inline__ __attribute__((always_inline)) IO& W(const vector<T>& x) {
    for (auto& i : x) WS(i);
    WL();
    return *this;
  }
  __inline__ __attribute__((always_inline)) IO& WL() {
    W('\n');
    return *this;
  }
  template <typename T1, typename T2>
  __inline__ __attribute__((always_inline)) IO& W(const pair<T1, T2>& x) {
    WS(x.first), W(x.second);
    return *this;
  }
  template <typename T>
  __inline__ __attribute__((always_inline)) IO& WL(const T& x) {
    W(x), W('\n');
    return *this;
  }
  __inline__ __attribute__((always_inline)) IO& WS() {
    W(' ');
    return *this;
  }
  template <typename T>
  __inline__ __attribute__((always_inline)) IO& WS(const T& x) {
    W(x), W(space);
    return *this;
  }
  template <typename T>
  __inline__ __attribute__((always_inline)) IO& WA(T* a, int n) {
    for (int i = 0; i < n; i++) WS(a[i]);
    WL();
    return *this;
  }
  template <typename T, typename... Args>
  __inline__ __attribute__((always_inline)) IO& W(const T& x,
                                                  const Args&... args) {
    W(x), W(space), W(args...);
    return *this;
  }
  template <typename... Args>
  __inline__ __attribute__((always_inline)) IO& WL(const Args&... args) {
    W(args...), W('\n');
    return *this;
  }
  template <typename T, typename... Args>
  __inline__ __attribute__((always_inline)) IO& WA(T* a, int n, Args... args) {
    for (int i = 0; i < n; i++) WA(a[i], args...);
    return *this;
  }
  template <typename T>
  __inline__ __attribute__((always_inline)) IO& W(const T& x) {
    static_assert(is_integral<T>::value, "Unsupported types");
    if (is_integral<T>::value) __WI(x);
    return *this;
  }
  template <typename T>
  __inline__ __attribute__((always_inline)) IO& operator>>(T& x) {
    R(x);
    return *this;
  }
  template <typename T>
  __inline__ __attribute__((always_inline)) IO& operator<<(const T& x) {
    W(x);
    return *this;
  }
  bool good() { return ok; }
  IO() {}
  ~IO() { flush(); }
} io;
const int32_t INF = 0x3f3f3f3f;
const int64_t INFL = 0x3f3f3f3f3f3f3f3fLL;
void solve() {
  int n;
  io >> n;
  priority_queue<int> q[2];
  for (int i = 1; i <= n; i++) q[i & 1].push(i);
  vector<pair<int, int>> ans;
  while (q[0].size() > 1 || q[1].size() > 1) {
    if (q[0].size() > 1 && q[1].size() > 1) {
      int x = q[0].top();
      q[0].pop();
      int y = q[0].top();
      int u = q[1].top();
      q[1].pop();
      int v = q[1].top();
      if (x + y > u + v) {
        q[0].pop();
        q[1].push(u);
        ans.emplace_back(x, y);
        int t = (x + y + 1) / 2;
        q[t & 1].push(t);
      } else {
        q[1].pop();
        q[0].push(x);
        ans.emplace_back(u, v);
        int t = (u + v + 1) / 2;
        q[t & 1].push(t);
      }
    } else if (q[0].size() > 1) {
      int x = q[0].top();
      q[0].pop();
      int y = q[0].top();
      q[0].pop();
      ans.emplace_back(x, y);
      int t = (x + y + 1) / 2;
      q[t & 1].push(t);
    } else {
      int u = q[1].top();
      q[1].pop();
      int v = q[1].top();
      q[1].pop();
      ans.emplace_back(u, v);
      int t = (u + v + 1) / 2;
      q[t & 1].push(t);
    }
  }
  if (q[0].size() + q[1].size() == 2) {
    int x = q[0].top();
    q[0].pop();
    int y = q[1].top();
    q[1].pop();
    ans.emplace_back(x, y);
    int z = (x + y + 1) / 2;
    q[z & 1].push(z);
  }
  if (q[0].size() == 1)
    io.WL(q[0].top());
  else
    io.WL(q[1].top());
  for (auto [x, y] : ans) {
    io.WL(x, y);
  }
}
int main() {
  int T;
  io >> T;
  while (T--) solve();
  return 0;
}

```