DFS logged solution
UVa problems