#include <bits/stdc++.h>
using namespace std;
using namespace chrono;
void _print(long long t) { cerr << t; }
void _print(int t) { cerr << t; }
void _print(string t) { cerr << t; }
void _print(char t) { cerr << t; }
void _print(long double t) { cerr << t; }
void _print(double t) { cerr << t; }
void _print(unsigned long long t) { cerr << t; }
template <class T, class V>
void _print(pair<T, V> p);
template <class T>
void _print(vector<T> v);
template <class T>
void _print(set<T> v);
template <class T, class V>
void _print(map<T, V> v);
template <class T>
void _print(multiset<T> v);
template <class T, class V>
void _print(pair<T, V> p) {
  cerr << "{";
  _print(p.first);
  cerr << ",";
  _print(p.second);
  cerr << "}";
}
template <class T>
void _print(vector<T> v) {
  cerr << "[ ";
  for (T i : v) {
    _print(i);
    cerr << " ";
  }
  cerr << "]";
}
template <class T>
void _print(set<T> v) {
  cerr << "[ ";
  for (T i : v) {
    _print(i);
    cerr << " ";
  }
  cerr << "]";
}
template <class T>
void _print(multiset<T> v) {
  cerr << "[ ";
  for (T i : v) {
    _print(i);
    cerr << " ";
  }
  cerr << "]";
}
template <class T, class V>
void _print(map<T, V> v) {
  cerr << "[ ";
  for (auto i : v) {
    _print(i);
    cerr << " ";
  }
  cerr << "]";
}
void print(long long t) { cout << t; }
void print(int t) { cout << t; }
void print(string t) { cout << t; }
void print(char t) { cout << t; }
void print(long double t) { cout << t; }
void print(double t) { cout << t; }
void print(unsigned long long t) { cout << t; }
template <class T>
void print(vector<T> v) {
  for (T i : v) {
    print(i);
    cout << " ";
  }
  cout << "\n";
}
template <class T>
void print(set<T> v) {
  for (T i : v) {
    print(i);
    cout << " ";
  }
  cout << "\n";
}
template <class T>
void print(multiset<T> v) {
  for (T i : v) {
    print(i);
    cout << " ";
  }
  cout << "\n";
}
long long gcd(long long a, long long b) {
  if (b == 0) {
    return a;
  }
  return gcd(b, a % b);
};
long long lcm(long long a, long long b) { return (a / (gcd(a, b))) * b; };
long long mod_add(long long a, long long b, long long m) {
  a = a % m;
  b = b % m;
  return (((a + b) % m) + m) % m;
}
long long mod_mul(long long a, long long b, long long m) {
  a = a % m;
  b = b % m;
  return (((a * b) % m) + m) % m;
}
long long mod_sub(long long a, long long b, long long m) {
  a = a % m;
  b = b % m;
  return (((a - b) % m) + m) % m;
}
long long ceil_div(long long a, long long b) {
  if (a % b == 0) return a / b;
  return a / b + 1;
}
bool perf_sq(long long x) {
  if (x >= 0) {
    long long sr = (long long)sqrtl(x);
    return (sr * sr == x);
  }
  return false;
}
vector<long long> spf(int n) {
  vector<long long> p(n + 1, 0);
  p[1] = 0;
  for (long long i = 2; i <= n; i++) {
    if (p[i] == 0) {
      p[i] = i;
      for (long long j = i * i; j <= n; j = j + i) {
        if (p[j] == 0) p[j] = i;
      }
    }
  }
  return p;
}
string alp = "abcdefghijklmnopqrstuvwxyz";
void solution() {
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    multiset<int> m;
    for (int i = 1; i <= n; i++) m.insert(i);
    vector<int> ans;
    for (int i = 0; i < n - 1; i++) {
      auto it1 = prev(m.end());
      int x = *it1;
      m.erase(it1);
      auto it2 = prev(m.end());
      int y = *it2;
      m.erase(it2);
      int k = x + y;
      int temp = (k % 2 == 0) ? k / 2 : k / 2 + 1;
      m.insert(temp);
      ans.push_back(x);
      ans.push_back(y);
    }
    cout << *m.begin() << "\n";
    int k = 0;
    for (int i = 0; i < n - 1; i++) {
      cout << ans[k] << " " << ans[k + 1] << "\n";
      k += 2;
    }
    cout << "\n";
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  auto start1 = high_resolution_clock::now();
  cout << fixed << setprecision(2);
  solution();
  auto stop1 = high_resolution_clock::now();
  auto duration = duration_cast<microseconds>(stop1 - start1);
  return 0;
}

### Prompt

Please create a solution in CPP 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;
using namespace chrono;
void _print(long long t) { cerr << t; }
void _print(int t) { cerr << t; }
void _print(string t) { cerr << t; }
void _print(char t) { cerr << t; }
void _print(long double t) { cerr << t; }
void _print(double t) { cerr << t; }
void _print(unsigned long long t) { cerr << t; }
template <class T, class V>
void _print(pair<T, V> p);
template <class T>
void _print(vector<T> v);
template <class T>
void _print(set<T> v);
template <class T, class V>
void _print(map<T, V> v);
template <class T>
void _print(multiset<T> v);
template <class T, class V>
void _print(pair<T, V> p) {
  cerr << "{";
  _print(p.first);
  cerr << ",";
  _print(p.second);
  cerr << "}";
}
template <class T>
void _print(vector<T> v) {
  cerr << "[ ";
  for (T i : v) {
    _print(i);
    cerr << " ";
  }
  cerr << "]";
}
template <class T>
void _print(set<T> v) {
  cerr << "[ ";
  for (T i : v) {
    _print(i);
    cerr << " ";
  }
  cerr << "]";
}
template <class T>
void _print(multiset<T> v) {
  cerr << "[ ";
  for (T i : v) {
    _print(i);
    cerr << " ";
  }
  cerr << "]";
}
template <class T, class V>
void _print(map<T, V> v) {
  cerr << "[ ";
  for (auto i : v) {
    _print(i);
    cerr << " ";
  }
  cerr << "]";
}
void print(long long t) { cout << t; }
void print(int t) { cout << t; }
void print(string t) { cout << t; }
void print(char t) { cout << t; }
void print(long double t) { cout << t; }
void print(double t) { cout << t; }
void print(unsigned long long t) { cout << t; }
template <class T>
void print(vector<T> v) {
  for (T i : v) {
    print(i);
    cout << " ";
  }
  cout << "\n";
}
template <class T>
void print(set<T> v) {
  for (T i : v) {
    print(i);
    cout << " ";
  }
  cout << "\n";
}
template <class T>
void print(multiset<T> v) {
  for (T i : v) {
    print(i);
    cout << " ";
  }
  cout << "\n";
}
long long gcd(long long a, long long b) {
  if (b == 0) {
    return a;
  }
  return gcd(b, a % b);
};
long long lcm(long long a, long long b) { return (a / (gcd(a, b))) * b; };
long long mod_add(long long a, long long b, long long m) {
  a = a % m;
  b = b % m;
  return (((a + b) % m) + m) % m;
}
long long mod_mul(long long a, long long b, long long m) {
  a = a % m;
  b = b % m;
  return (((a * b) % m) + m) % m;
}
long long mod_sub(long long a, long long b, long long m) {
  a = a % m;
  b = b % m;
  return (((a - b) % m) + m) % m;
}
long long ceil_div(long long a, long long b) {
  if (a % b == 0) return a / b;
  return a / b + 1;
}
bool perf_sq(long long x) {
  if (x >= 0) {
    long long sr = (long long)sqrtl(x);
    return (sr * sr == x);
  }
  return false;
}
vector<long long> spf(int n) {
  vector<long long> p(n + 1, 0);
  p[1] = 0;
  for (long long i = 2; i <= n; i++) {
    if (p[i] == 0) {
      p[i] = i;
      for (long long j = i * i; j <= n; j = j + i) {
        if (p[j] == 0) p[j] = i;
      }
    }
  }
  return p;
}
string alp = "abcdefghijklmnopqrstuvwxyz";
void solution() {
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    multiset<int> m;
    for (int i = 1; i <= n; i++) m.insert(i);
    vector<int> ans;
    for (int i = 0; i < n - 1; i++) {
      auto it1 = prev(m.end());
      int x = *it1;
      m.erase(it1);
      auto it2 = prev(m.end());
      int y = *it2;
      m.erase(it2);
      int k = x + y;
      int temp = (k % 2 == 0) ? k / 2 : k / 2 + 1;
      m.insert(temp);
      ans.push_back(x);
      ans.push_back(y);
    }
    cout << *m.begin() << "\n";
    int k = 0;
    for (int i = 0; i < n - 1; i++) {
      cout << ans[k] << " " << ans[k + 1] << "\n";
      k += 2;
    }
    cout << "\n";
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  auto start1 = high_resolution_clock::now();
  cout << fixed << setprecision(2);
  solution();
  auto stop1 = high_resolution_clock::now();
  auto duration = duration_cast<microseconds>(stop1 - start1);
  return 0;
}

```