So I recently saw this problem in one of the blogs and someone claimed to have solved is using brute force, so I gave it a try and it seems that this 3100 rated has weak tc. When I tried to submit using some optimisations, it got accepted (311356622). Can anyone tell any reason why is it so?