How to solve this problem ?
Problem Link — https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&category=738&page=show_problem&problem=5931