This problem statement is [here](https://mirror.codeforces.com/problemset/problem/453/E)↵
I read the editorial but cannot understand how it works, then i came up with the sqrt decomposition solution.↵
However i still want to grasp the full solution written in the editorial , i think the full solution of this problem may be useful for me in the future when i meet some kind of problems like that, (when sqrt solution is impossible).↵
Thanks in advance.
I read the editorial but cannot understand how it works, then i came up with the sqrt decomposition solution.↵
However i still want to grasp the full solution written in the editorial , i think the full solution of this problem may be useful for me in the future when i meet some kind of problems like that, (when sqrt solution is impossible).↵
Thanks in advance.



