change list to collections.deque
sol of q126