Consider all permutations of , listed in lexicographic order. For example, for , the list starts as follows:
Let us call a permutation unpredictable if there is no choice of three indices such that , and constitute an arithmetic progression. For example, is not unpredictable because is an arithmetic progression.
Let be the position within the list of the first unpredictable permutation.
For example, given , the first unpredictable permutation is so .
You are also given that and .
Find . Give your answer modulo .
Write-up coming later
The complete problem is available here. An approach, code, and answer will be added later.