A hash function h_n is given, which encrypts the number A, consisting of 2n bits, as follows:
Let A=(a_2n−1a_2n−2⋯a_1a_0)_2, that is, a_i is the i-th bit of the number A.
The number B=(b_2n−1b_2n−2⋯b_1b_0)_2, also consisting of 2n bits, is calculated as follows: b_i=a_i⊕a_2i+1, for 0≤i<n, b_i=a_i⊕a_4n−2i−2, for n≤i<2n, where ⊕ is bitwise exclusive OR (XOR). In other words, B=A⊕(a_0a_2⋯a_2n−4a_2n−2a_2n−1a_2n−3⋯a_3a_1)_2.
Next, the number C=B⊕RSH(B) is calculated, also consisting of 2n bits, where RSH(B) is a cyclic right shift by 1 bit. In other words, C=B⊕(b_0b_2n−1b_2n−2⋯b_2b_1)_2.
Finally, the hash value is calculated as h_n(A)=239A+153Cmod(22n−1−1).
For example, let n=4 and A=00001101_2=13.
Then, B=00001101_2⊕11000010_2=11001111_2=207.
Further, C=11001111_2⊕11100111_2=00101000_2=40.
Finally, h_4(A)=239×13+153×40mod(27−1)=9,227mod127=83.
Your goal is to invert this hash function, that is, for given n and H, find A such that h_n(A)=H.