Final Solution for Magic Trick problem