Link:https://mirror.codeforces.com/gym/104686/problem/F
Actually I have trouble reading the editorial(it's too brief for me to understand),so now I'm here trying to get a more detailed editorial of this problem.If anyone knows the solution,help me pls.