------
## 最终结论
```python
import sys

input = sys.stdin.read
data = input().split()

t = int(data[0])
index = 1
results = []

for _ in range(t):
    n = int(data[index])
    index += 1
    
    # The minimum possible number that can be left on the board is always 2
    results.append(str(2))
    
    # Perform operations to achieve the minimum number
    for i in range(2, n + 1):
        results.append(f"{i} {n}")

print("\n".join(results))
```