Solved ZigZag problem