Truveta's data-processing components may need LIFO behavior even when only queue primitives are available. Implement a stack using exactly two queues.
Given a sequence of operations, process each operation and return the values produced by pop operations. The stack must follow last-in, first-out order.
Implement stack_with_two_queues(operations), where operations is a list of dictionaries. Each dictionary is either {"op": "push", "value": integer} or {"op": "pop"}. Return a list containing the integer removed by every pop, or None when pop is called on an empty stack.
Your implementation must maintain two queue instances and may use only queue-style operations, such as adding to the back, removing from the front, checking length, and checking whether a queue is empty. Do not use a list as the underlying stack.
def stack_with_two_queues(operations):