Loading repovive.com/contests/9/problems/F
You are given an array .
You perform the following operation exactly times.
Choose two integers and uniformly at random among all pairs satisfying , then reverse the subarray .
The operations are independent.
The beauty of an array is defined as
Compute the expected value of the beauty of the final array modulo .
Formally, if the expected value can be written as an irreducible fraction , output modulo .
The array has only one element, so the beauty is always .
No operation is performed, so the beauty remains .
There are possible segments, and the expected beauty is .
After one operation, the expected beauty is .
This is a larger sample with and .