the easiest solution would be to use one stack as the head of the queue and one as the tail. Queue operations can be just pushing the corresponding stack, and detection operations will simply pop into the corresponding stack.
, , , , , , . , . , . , , , , .
,