Traditionally, few students attended history classes, so the teacher decided to change the system and introduce mandatory group projects for students, which can only be completed in person during classes. Now all $n$ students, numbered from $1$ to $n$, attend the classes. The teacher knows that the knowledge level of the $i$-th student is $a_i$.

To complete the group project, students need to form pairs. To make this not too simple, the teacher has set the following requirement: two people with numbers $i \neq j$ can be paired if either $a_i + a_j = S$, or $a_i \oplus a_j = X$, where $\oplus$ denotes the bitwise exclusive OR (XOR) operation.

Help the students determine if it is possible to form pairs in such a way that the teacher's requirements are satisfied.