755_E. PolandBall and White-Red graph
PolandBall has an undirected simple graph consisting of n vertices. Unfortunately, it has no edges. The graph is very sad because of that. PolandBall wanted to make it happier, adding some red edges. Then, he will add white edges in every remaining place. Therefore, the final graph will be a clique in two colors: white and red. 

Colorfulness of the graph is a value min(dr, dw), where dr is the diameter of the red subgraph and dw is the diameter of white subgraph. The diameter of a graph is a largest value d such that shortest path between some pair of vertices in it is equal to d. If the graph is not connected, we consider its diameter to be -1.

PolandBall wants the final graph to be as neat as possible. He wants the final colorfulness to be equal to k. Can you help him and find any graph which satisfies PolandBall's requests?

Input

The only one input line contains two integers n and k (2 ≤ n ≤ 1000, 1 ≤ k ≤ 1000), representing graph's size and sought colorfulness.

Output

If it's impossible to find a suitable graph, print -1.

Otherwise, you can output any graph which fulfills PolandBall's requirements. First, output m — the number of red edges in your graph. Then, you should output m lines, each containing two integers ai and bi, (1 ≤ ai, bi ≤ n, ai ≠ bi) which means that there is an undirected red edge between vertices ai and bi. Every red edge should be printed exactly once, you can print the edges and the vertices of every edge in arbitrary order.

Remember that PolandBall's graph should remain simple, so no loops or multiple edges are allowed.

Examples

Input

4 1


Output

-1


Input

5 2


Output

4
1 2
2 3
3 4
4 5

Note

In the first sample case, no graph can fulfill PolandBall's requirements.

In the second sample case, red graph is a path from 1 to 5. Its diameter is 4. However, white graph has diameter 2, because it consists of edges 1-3, 1-4, 1-5, 2-4, 2-5, 3-5.
```python

def PolandBall(n, k):
    # condiciones que no cumplen con los requisitos
    if n < 4 or k > 3 or k == 1 or (k == 2 and n == 4):
        print('-1')
        return

    # si k=2
    if k == 2:
        print(n-1)
        for i in range(1, n):
            print(str(i)+' '+str(i+1))
        return

    # si k=3 y n=4
    if n == 4:
        print(n-1)
        print('1 2')
        print('2 3')
        print('3 4')
        return

     # si k=3 y n>4
    print(n)
    print('1 2')
    print('2 3')
    print('1 4')
    print('3 5')
    for i in range(5, n+1):
        print('1 '+str(i))


n, k = map(int, input().split())
PolandBall(n, k)

# Casos de prueba:
# 4 1  ##respuesta -1
# 5 2  ##respuesta  4

# 2 1        ##respuesta -1
# 2 3        ##respuesta -1
# 3 3        ##respuesta -1

# 4 2        ##respuesta -1
# 7 2        ##respuesta 6
# 100 2      ##respuesta 99
# 500 2      ##respuesta 499
# 1000 2     ##respuesta 999

# 4 3        ##respuesta 3
# 7 3        ##respuesta 7
# 100 3      ##respuesta 100
# 500 3      ##respuesta 500
# 1000 3     ##respuesta 1000

# 1000 1000  ##respuesta -1

```