D. Xor sum Atcoder Beginner contest 50

Link to question

can some please help me in this question. The editorial uses a dp solution,but I am unable to understand why it works.

I understand that if u= a xor b & v=a + b => v=u+2*(a&b)
but beyond that, I am clueless.

Please help!!