Misimplemented Dinic

Print a fixed 4-vertex, 5-edge flow network; there is no input and the output is a single constant graph.

Easy3GraphBrute forceImplementationNo attempts yetTime limit2sMemory limit512 MB

Problem

Jigui always solves flow problems with the Edmond-Karp algorithm. One day Jigui saw a flow problem with 500 vertices and 100000 edges. Jigui built a flow graph, wrote about 2000 bytes of code, and submitted it, but the submission was not accepted. Tired of tuning the code, Jigui found Dinic's algorithm, whose worst-case time complexity is O(V2E)O(V^2 E).

Dinic's algorithm is as follows.

  1. Treat every residual edge as an edge of length 1 and compute the shortest-path distance dvd_v from the source to every vertex.
  2. Find an augmenting path with DFS and push flow. Push flow on an edge uvu \to v only when du+1=dvd_u + 1 = d_v.
  3. Repeat steps 1 and 2 until no more flow can be pushed.

The O(V2E)O(V^2 E) bound is justified as follows.

  1. Steps 1 and 2 run at most O(V)O(V) times. Each run increases dsinkd_{\mathrm{sink}} by at least 1, and dsinkd_{\mathrm{sink}} cannot exceed VV.
  2. Step 1 is O(E)O(E). It can be computed with BFS.
  3. Step 2 is O(VE)O(VE). Each time flow is pushed, at least one edge becomes saturated, so there are at most O(E)O(E) augmenting paths. Each augmenting path has length at most VV.

Jigui implemented the algorithm carefully and still did not get an accepted verdict. Dotori looked at the code and pointed out a small mistake: when the search for an augmenting path starts, edges that cannot carry more flow are scanned from the beginning of the adjacency list every time. Jigui will not believe this until a small example graph is shown.

Help Dotori print that example graph. The graph to print is unique.

The problem Jigui is solving sends flow from vertex 1 to vertex NN. Edges are stored in a linked list, and a new edge is inserted at the front of the list, so a later input edge is used first.

Input

There is no input.

Output

Print the number of vertices NN and the number of edges MM on the first line. NN is 44 and MM is 55.

Then print MM lines, each with a start vertex ss, an end vertex ee, and a capacity ff, in this order:

  • from 11 to 22 with capacity 33
  • from 11 to 33 with capacity 44
  • from 11 to 44 with capacity 55
  • from 22 to 44 with capacity 22
  • from 33 to 44 with capacity 22

The graph has no duplicate edges. Each line prints the integers ss, ee, and ff in that order, separated by spaces.