anybody explain me last test case output 10 i am getting 11.
sample input
5
3 8
2 3
1 2
2 4
3 6
sample output
14
5
2
6
10
another things i am not getting
following statement of problem
"
If the destination node is already visited, Amr skips current command, otherwise he moves to the destination node;
If Amr skipped two consecutive commands, he goes back to the parent of the current node before executing next command;
If he reached a leaf node that is not the exit, he returns to the parent of the current node;
"