A graph (other than a complete graph) has connectivity k if k is the size of the smallest subset of vertices such that the graph becomes disconnected if you delete them.
A connected undirected graph G is called Hamiltonian if it has a Hamiltonian cycle: a cycle that visits each vertex exactly once (except for the vertex that is both the start and the end, which is visited twice).
Bobo would like to construct a Hamiltonian graph with n vertices which has connectivity k. Also, the number of edges in the graph should be minimum possible.
The first line contains two integers n and k where n is the number of vertices in the graph (3≤n≤100, 1≤k≤n−2).
If there is no such graph, output −1 on a single line. Otherwise, output an integer m denoting the minimum number of edges. Then in each of the next m lines, output two integers x and y (1≤x,y≤n, x=y) denoting an edge in the graph. In the following line, output a permutation of integers 1,2,…,n denoting a Hamiltonian cycle in the graph.