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