시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율
2 초 512 MB 0 0 0 0.000%

문제

Harry is a mathematician who likes to play with graphs. He has drawn a weighted undirected graph on the blackboard, and computed that the length of the shortest path between two nodes is s. Unfortunately he has to leave the room, therefore he quickly writes down s and the weights of all edges on a piece of paper, and he wipes the blackboard. Then it dawns on him: this information is not enough to reconstruct his beautiful graph!

Write a program that constructs some graph matching the information that Harry wrote down.

입력

The input consists of:

  • one line with two integers s and e (1 ≤ s ≤ 104, 1 ≤ e ≤ 1 000), the length of the shortest path and the number of edges;
  • e lines, each with an integer w (0 ≤ w ≤ 104), the length of an edge.

출력

Output a graph consisting of a number of 1-indexed nodes and exactly e edges, such that the edge lengths correspond to the lengths in the input, and the length of the shortest path between nodes 1 and 2 is s. The graph must be connected, must not contain self-loops and can have at most one edge between each pair of nodes. You may assume that such a graph exists.

The output must consist of:

  • one line with an integer n (2 ≤ n ≤ e + 1), the number of nodes;
  • e lines, each with three integers a, b and w (1 ≤ a, b ≤ n), describing an edge between nodes a and b with length w.

If there are multiple correct answers, you may give any of them.

예제 입력 1

4 5
1
5
3
2
2

예제 출력 1

4
1 3 1
1 4 2
4 2 2
3 2 3
3 4 5