The longest path
Medium
Execution time limit is 1 second
Runtime memory usage limit is 128 megabytes
In an oriented graph find the longest path such that each vertex of the graph occurs no more than once in it.
Input
First line contains two integers n and m (1 ≤ n ≤ 22, 0 ≤ m ≤ 1000). Each of the next m lines contains the edges of the graph in format u[i] v[i]
- the numbers of starting and ending vrtices of the edge i. Graph can contain loops and multiedges.
Output
In the first line, output the length of the longest path l. In the second line print l + 1 number - the vertices of the path in the order of traversal. If there are several optimal answers, output any of them.
Examples
Input #1
Answer #1
Input #2
Answer #2
Input #3
Answer #3
Submissions 512
Acceptance rate 8%