Sanvi and Happy Pairs

Limits 2s, 1.0 GB

Sanvi is a very little and so much cute girl. She was playing with an array A of length N. While doing so, Sanvi discovers an interesting pattern with the pairing of two elements in that array. She defines a term ‘Happy Pair’ as pairing of two integer numbers, say P and Q, if bitwise XOR of these integers is a power of 2 i.e ( P XOR Q = 2^X ) , where X is an integer number. Now, she is challenging you with the following task.

This is a companion discussion topic for the original entry at