

For given N = 4, M = 4, S = 0 and D =3.

In the above example, the path 0 -> 1 - > 3 is a valid path as all nodes along the path are unique and the path 0 -> 1 -> 2 -> 1 -> 3 is not a valid path because node 1 is visited twice.
The first line contains one positive integer ‘T’, denoting the number of test cases, then ‘T’ test cases follows.
The first line of each test case contains two integers ‘N’ and ‘M’, denoting the number of nodes and the number of edges.
The next ‘M’ lines of each test case contains two space-separated integers ’u’ and ‘v’, denoting the edge between ‘u’ and ‘v’.
The last line of each test case contains two integers ‘S’ and ‘D’ denoting the source and destination.
The first line of each test case contains an integer ‘N’ , denoting the number of valid paths from ‘S’ to ‘D’.
The next ‘N’ line of each test case contains the all nodes from ‘S’ to ‘D’ along the ‘ith’ path where 1 <= i <= N.
If there are more than one path then the ith path should be lexicographically smaller than (i + 1) path.
Output of each test case will be printed on a separate line.
You do not need to print anything, it has already been taken care of. Just implement the given function.
1 <= T <= 5
1 <= N <= 5
1 <= M <= 10
0 <= u, v , S, D <= N - 1
Time Limit: 1 sec.
The idea is very simple: we will perform dfs from a given source node and try out all possible paths using the backtracking concept.
The steps are as follows:
Let ‘allAllPaths(n, m, edges, src, des)’ be the function that returns a 2D array that contains all the possible paths.