BAPC training week 4: stacks and DFS