atcoder#ABC131E. [ABC131E] Friendships

[ABC131E] Friendships

Score: 500500 points

Problem Statement

Does there exist an undirected graph with NN vertices satisfying the following conditions?

  • The graph is simple and connected.
  • The vertices are numbered 1,2,...,N1, 2, ..., N.
  • Let MM be the number of edges in the graph. The edges are numbered 1,2,...,M1, 2, ..., M, the length of each edge is 11, and Edge ii connects Vertex uiu_i and Vertex viv_i.
  • There are exactly KK pairs of vertices (i, j) (i<j)(i,\ j)\ (i < j) such that the shortest distance between them is 22.

If there exists such a graph, construct an example.

Constraints

  • All values in input are integers.
  • 2N1002 \leq N \leq 100
  • 0KN(N1)20 \leq K \leq \frac{N(N - 1)}{2}

Input

Input is given from Standard Input in the following format:

NN KK

Output

If there does not exist an undirected graph with NN vertices satisfying the conditions, print -1.

If there exists such a graph, print an example in the following format (refer to Problem Statement for what the symbols stand for):

MM

u1u_1 v1v_1

::

uMu_M vMv_M

If there exist multiple graphs satisfying the conditions, any of them will be accepted.

5 3
5
4 3
1 2
3 1
4 5
2 3

This graph has three pairs of vertices such that the shortest distance between them is 22: (1, 4)(1,\ 4), (2, 4)(2,\ 4), and (3, 5)(3,\ 5). Thus, the condition is satisfied.

5 8
-1

There is no graph satisfying the conditions.