Print out the stack at every change at the beginning and the end also