Given multiple exchanges and multiple symbols, code a quote handler and a query function to retrieve the last quote for a given symbol.
Implement quote_handler(events, queries). Each event is [exchange, symbol, timestamp, bid, ask]; events may arrive out of timestamp order. Return one quote for each queried symbol, selecting the greatest timestamp across exchanges, with later input winning ties. Return None for an unknown symbol. The output quote must retain its original five-field format.
Constraints: 1 <= len(events) <= 5000, 0 <= len(queries) <= 5000, and timestamps, prices, exchange names, and symbols are valid comparable values.
def quote_handler(events, queries):