PROGRAMMING:Key activities
Suppose an engineering project is composed of a group of subtasks, some of which can be executed in parallel, and some of which can only be executed after other subtasks are completed“ "Task scheduling" includes a set of subtasks and a set of subtasks on which each subtask can execute.
For example, the completion of all courses and graduation design of a major can be regarded as a project to be completed by an undergraduate, and each course can be regarded as a subtask. Some courses can be offered at the same time, such as English and C programming, they do not have to take which course first; Some courses can't be offered at the same time, because they are dependent on each other. For example, C programming and data structure should be studied first.
However, it should be noted that for a group of subtasks, not any task scheduling is a feasible solution. For example, in the scheme, "subtask a depends on subtask B, subtask B depends on subtask C, and subtask C depends on subtask a", then none of the three tasks can be executed first, which is an infeasible scheme.
In the task scheduling problem, if we also give the time needed to complete each sub task, we can calculate the shortest time needed to complete the whole project. Among these subtasks, even if some tasks are delayed for a few days, the global duration will not be affected; However, some tasks must be completed on time, otherwise the whole project will be delayed. This kind of task is called "key activity".
Please write a program to determine whether the task scheduling of a given project is feasible; If the scheduling scheme is feasible, the shortest time needed to complete the whole project is calculated, and all the key activities are output.
###Input format:
Enter the first line to give two positive integers $$n $$($$Le 100 $$) and $$M $$, where $$n $$is the number of task handover points (that is, nodes connecting two interdependent subtasks, for example, if task 2 starts after task 1 is completed, there must be a handover point between two tasks). The handover points are numbered by 1 ~ $$n $$, $$M $$is the number of subtasks, which are numbered by 1 ~ $$M $$. Then, in the $$M $$line, each line gives three positive integers, which are the number of the junction point involved in the start and completion of the task and the time required for the task, and the integers are separated by spaces.
###Output format:
If the task scheduling is not feasible, output 0; Otherwise, the first line outputs the time needed to complete the whole project, and the second line starts to output all the key activities, each of which occupies one line. The output is in the format of "V - > W", where V and W are the number of the handover point involved in the start and completion of the task. The sequence rule of key activity output is: priority is given to the small number of the starting point of the task. When the starting point number is the same, the sequence of the input task is opposite.
###Input example:
```in
7 8
1 2 4
1 3 3
2 4 5
3 4 3
4 5 1
4 6 6
5 7 5
6 7 2
```
###Output example:
```out
seventeen
1->2
2->4
4->6
6->7
```
answer:If there is no answer, please comment
For example, the completion of all courses and graduation design of a major can be regarded as a project to be completed by an undergraduate, and each course can be regarded as a subtask. Some courses can be offered at the same time, such as English and C programming, they do not have to take which course first; Some courses can't be offered at the same time, because they are dependent on each other. For example, C programming and data structure should be studied first.
However, it should be noted that for a group of subtasks, not any task scheduling is a feasible solution. For example, in the scheme, "subtask a depends on subtask B, subtask B depends on subtask C, and subtask C depends on subtask a", then none of the three tasks can be executed first, which is an infeasible scheme.
In the task scheduling problem, if we also give the time needed to complete each sub task, we can calculate the shortest time needed to complete the whole project. Among these subtasks, even if some tasks are delayed for a few days, the global duration will not be affected; However, some tasks must be completed on time, otherwise the whole project will be delayed. This kind of task is called "key activity".
Please write a program to determine whether the task scheduling of a given project is feasible; If the scheduling scheme is feasible, the shortest time needed to complete the whole project is calculated, and all the key activities are output.
###Input format:
Enter the first line to give two positive integers $$n $$($$Le 100 $$) and $$M $$, where $$n $$is the number of task handover points (that is, nodes connecting two interdependent subtasks, for example, if task 2 starts after task 1 is completed, there must be a handover point between two tasks). The handover points are numbered by 1 ~ $$n $$, $$M $$is the number of subtasks, which are numbered by 1 ~ $$M $$. Then, in the $$M $$line, each line gives three positive integers, which are the number of the junction point involved in the start and completion of the task and the time required for the task, and the integers are separated by spaces.
###Output format:
If the task scheduling is not feasible, output 0; Otherwise, the first line outputs the time needed to complete the whole project, and the second line starts to output all the key activities, each of which occupies one line. The output is in the format of "V - > W", where V and W are the number of the handover point involved in the start and completion of the task. The sequence rule of key activity output is: priority is given to the small number of the starting point of the task. When the starting point number is the same, the sequence of the input task is opposite.
###Input example:
```in
7 8
1 2 4
1 3 3
2 4 5
3 4 3
4 5 1
4 6 6
5 7 5
6 7 2
```
###Output example:
```out
seventeen
1->2
2->4
4->6
6->7
```
answer:If there is no answer, please comment