Preprocessing takes to build the tree structure and perform HLD decomposition. Building the segment tree takes . Each QUERY walks chains and does work per chain via segment tree queries, giving per query.
Each CHANGE is a single segment tree point update, taking time. Total time: , which handles the constraints comfortably.
Space complexity is for the data structures used.