Can anybody please explain how to solve this problem (with proof)?
https://www.spoj.com/problems/BALIFE/
ABC 483 problems EFG (part 2)