Help needed in HXOR. Cant't pass test case 4

Tried trivial approach. Tried the approach presented by codechef itself on youtube. Picked an element from i = 0 to second last and began XORing it with it 2 ** MSBindex. Picked j such that XORing it leads to it getting decreased or XORing the last element as default.
Checked corner case of n = 2 and x = 1.

Code link
https://www.codechef.com/viewsolution/40448520

for test case like
3 2
2 2 3

Your Output: 0 1 2
Correct Output: 0 0 3

2 2 3
2 0 1 (xor 2, p =1)
0 0 3 (xor 2, p =1)

Thankyou so much for replying. Just read about the dummy operation. I think only the corner case of n = 2 needs to be handled. Cheers!

when you took xor in first step with 1, how can you get 1 1 3, it should rather become 3 3 3.

I also tried this test case during the contest and the output should be 0 1 2 like so :
0 0 3 (xor with 2 (p = 1 as per the question))
0 1 2 (xor with 1 (p = 0))

sorry my bad its,
2 2 3
2 0 1 (xor 2, p =1)
0 0 3 (xor 2, p =1)

Yeah, I read the editorial, the smallest sequence should be 0 0 3, not 0 1 2.
Thanks for clearing things up

i was facing same problem the following test case was error:
1
4 4
2 5 5 9
Correct Ans: 0 0 0 11
but ur answer would be 0 0 2 9

Hi @bhavyeah98,
we both were having the same problem with the same code, I added some changes to your code and we got a fully correct solution. Cheers! Solution HXOR