Added the solution for stack3