Template
Code 1 : https://codeforces.me/contest/600/submission/68729075
Code 2 : https://codeforces.me/contest/570/submission/86307066
Code 3 : https://codeforces.me/contest/246/submission/86380797
Code 4 : https://codeforces.me/contest/208/submission/87172029
Code 5 : https://codeforces.me/contest/375/submission/86462196