https://www.acwing.com/solution/content/218914/
https://www.acwing.com/solution/content/218913/