implemented three stacks from an array