Under construction

Still being built. Things may change

Three-Step Tunnels

Time limit2sMemory limit512 MB

Summary
Given n buildings on a line, build at most 5n tunnels so every pair is joined by a monotone path of at most 3 tunnels.
Level

Medium7 of 10

Topics
Divide and conquer, Graph, Implementation
Solved
No attempts yet

Problem

A far away city has nn buildings located along a straight line going from left to right. Because the city is laid out in a straight line, traffic is always a nightmare.

A company has decided to connect the buildings with bidirectional underground tunnels to provide an alternative form of transportation. Each tunnel connects two buildings. To make navigation easy, the company requires that for any two different buildings aa and bb, it must be possible to get from aa to bb using only tunnels:

  • always going in the same direction: left to right if bb is to the right of aa, and right to left if bb is to the left of aa; and
  • using at most 3 tunnels.

Design a set of tunnels that satisfies these requirements and contains at most 5n5n tunnels. You do not need to find the smallest possible set.

Input

The only line of input contains a single integer nn (2≤n≤5002 \le n \le 500).

Output

On the first line, print the number mm of tunnels you propose to build. On each of the next mm lines, print two distinct integers, the numbers of the buildings connected by that tunnel. The buildings are numbered from 1 to nn from left to right.

mm must be less than or equal to 5n5n. You may print the tunnels in any order. All tunnels must be distinct. For example, you may not include both "1 2" and "2 1".

Examples1

  1. Example 1

    Input
    5
    
    Expected output
    5
    1 2
    2 3
    3 4
    4 5
    1 5