The 3-Regular Graph

The degree of a vertex in a graph is the number of edges adjacent to the vertex. A graph is 3-regular if all of its vertices have degree 3. Given an integer n, you are to build a simple undirected 3-regular graph with n vertices. If there are multiple solutions, any one will do. Input For each test case, the input will be a single integer n as described above. End of input will be denoted by a case where n = 0. This case should not be processed. Output If it is possible to build a simple undirected 3-regular graph with n vertices, print a line with an integer e which is the number of edges in your graph. Each of the following e lines describes an edge of the graph. An edge description contains two integers a and b, the two endpoints of the edge. Note that the vertices are indexed from 1 to n. If it is not possible to build a simple undirected 3-regular graph with n vertices, print ‘Impossible’ in a single line. Constraints • 1≤n≤100 Sample Input 4 3 0 Sample Output 6 12 13 14 23 24 34 Impossible