#abc131e. [abc131_e]Friendships
[abc131_e]Friendships
Problem Statement
Does there exist an undirected graph with vertices satisfying the following conditions?
- The graph is simple and connected.
- The vertices are numbered .
- Let be the number of edges in the graph. The edges are numbered , the length of each edge is , and Edge connects Vertex and Vertex .
- There are exactly pairs of vertices such that the shortest distance between them is .
If there exists such a graph, construct an example.
Constraints
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
Output
If there does not exist an undirected graph with 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):
If there exist multiple graphs satisfying the conditions, any of them will be accepted.
Sample Input 1
5 3
Sample Output 1
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 : , , and . Thus, the condition is satisfied.
Sample Input 2
5 8
Sample Output 2
-1
There is no graph satisfying the conditions.