Router 1

Print either a star-shaped router with one internal hub or a fully connected bipartite router, depending on whether N*N exceeds P_lim.

Easy3GraphImplementationSimulationNo attempts yetTime limit2sMemory limit512 MB

Problem

Henry and Hetty were hired by a networking company. Their first project is a new router, the Connect Ethernet Operating Interface, built from:

  • NN input nodes, numbered from 11 to NN;
  • NN output nodes, numbered from N+1N+1 to 2N2N;
  • KK internal nodes, numbered from 2N+12N+1 to 2N+K2N+K;
  • MM unidirectional direct connections, each joining two distinct nodes.

A node XX can send data to a node YY (equivalently, YY can receive data from XX) if one of the following holds:

  • X=YX = Y;
  • there is a node ZZ such that XX can send data to ZZ and a direct connection runs from ZZ to YY.

If XX can send data to YY and XYX \ne Y, the data path from XX to YY is the set of direct connections {(A1,A2),(A2,A3),,(AL1,AL)}\{(A_1, A_2), (A_2, A_3), \ldots, (A_{L-1}, A_L)\} with L2L \ge 2, A1=XA_1 = X and AL=YA_L = Y.

A router works properly when all of the following hold:

  • every input node can send data to every output node;
  • every input node can receive data only from itself;
  • every output node can send data only to itself;
  • for any two nodes XX and YY with XYX \ne Y, if XX can send data to YY, then YY cannot send data to XX;
  • for any two nodes XX and YY with XYX \ne Y, if XX can send data to YY, then the data path from XX to YY is unique. In particular, any two nodes are joined by at most one direct connection.

The power needed to operate node XX is PX=INX×OUTXP_X = IN_X \times OUT_X, where INXIN_X is the number of input nodes that can send data to XX and OUTXOUT_X is the number of output nodes that can receive data from XX. Writing Ntot=2N+KN_{tot} = 2N + K for the total number of nodes, the maximum power used by the router is Pmax=max(P1,P2,,PNtot)P_{max} = \max(P_1, P_2, \ldots, P_{N_{tot}}).

You are given NN, MlimM_{lim} and PlimP_{lim}. Build a router that works properly, has exactly NN input nodes and NN output nodes, uses at most MlimM_{lim} direct connections, has PmaxPlimP_{max} \le P_{lim}, and uses at most 500000500\,000 nodes in total. Several routers meet such a specification, so the output section fixes the single one you must print.

Input

One line with three integers NN, MlimM_{lim} and PlimP_{lim}: the number of input nodes and of output nodes, the largest number of direct connections allowed, and the largest power the router may use (1N10001 \le N \le 1000, 1Mlim1061 \le M_{lim} \le 10^6, 1Plim1061 \le P_{lim} \le 10^6).

It is guaranteed that NPlimN \le P_{lim} and that the router described in the output section uses at most MlimM_{lim} direct connections.

Output

Print the router picked by the rule below.

If N×NPlimN \times N \le P_{lim}, print the router with one internal node. It has Ntot=2N+1N_{tot} = 2N + 1 nodes and M=2NM = 2N direct connections: first the connections i2N+1i \to 2N+1 for i=1,2,,Ni = 1, 2, \ldots, N in increasing order of ii, then the connections 2N+1N+j2N+1 \to N+j for j=1,2,,Nj = 1, 2, \ldots, N in increasing order of jj.

Otherwise print the router with no internal node. It has Ntot=2NN_{tot} = 2N nodes and M=N×NM = N \times N direct connections, namely iN+ji \to N+j for every pair (i,j)(i, j), sorted by ii increasing and, for equal ii, by jj increasing.

The first line holds NtotN_{tot} and MM separated by a space. Each of the next MM lines holds two integers XX and YY, meaning a direct connection from node XX to node YY was built.