Hello Codeforces community, This is an editorial for an 11-year-old problem in CF, and the official editorial still has it TODO, so yeah, why not?
I'll use step-by-step guides to show case the path to finding the solution to this problem, and hope it'll be helpful to other people.
1. The intervals are given offline.
In this subtask, let's assume that the intervals are given two us, and the queries are asked after all the intervals are given.