Resource: https://rezwanarefin01.github.io/posts/block-decomposition-01/
Code. 1: http://lightoj.com/volume_showcode.php?sub_id=1659895
Code. 2: https://mirror.codeforces.com/contest/220/submission/78549141
Code. 3: https://mirror.codeforces.com/contest/86/submission/54223200
Code. 4: https://vjudge.net/contest/301430#status/shajib_1703025/K/0/