Implement a simplified order-book matching engine that processes a stream of buy and sell orders for a single stock and continuously matches them under price-time priority. Each order is a tuple (price, quantity, side) where side is either BUY or SELL. Maintain two books: a buy book ordered by highest price first (and earliest first if prices tie) and a sell book ordered by lowest price first (and earliest first if prices tie). When an order arrives, attempt to match it against the best opposite-side orders: a BUY can match any SELL whose price is <= the BUY price, taking the cheapest SELL first; a SELL can match any BUY whose price is >= the SELL price, taking the highest BUY first. Matches occur at the opposite order’s price and reduce quantities on both sides until one side is fully filled or no more matches are possible. Any residual quantity is appended to its own book. After each order is processed, output the total number of shares that have been executed across all trades so far.