A hash function h_n encrypts a number A consisting of 2n bits as follows.
Let A=(a_2n−1a_2n−2⋯a_1a_0)_2, where a_i is the i-th bit of A.
The number B=(b_2n−1b_2n−2⋯b_1b_0)_2, also consisting of 2n bits, is computed 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 computed, also consisting of 2n bits, where RSH(B) is a cyclic right shift of B by 1 bit. In other words, C=B⊕(b_0b_2n−1b_2n−2⋯b_2b_1)_2.
Finally, the hash value is 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. Next, C=11001111_2⊕11100111_2=00101000_2=40. Finally, h_4(A)=239×13+153×40mod(27−1)=9227mod127=83.
Your goal is to invert this hash function. For given n and H, find A such that h_n(A)=H.