#P2022M. Prefix XORs
Prefix XORs
Prefix XORs
Time Limit: 10s
Memory Limit: 1024 MB
Problem Statement
You are given an integer sequence of length : , and an integer .
For each , find the value of after doing the operation below times.
- For every , replace the value with .
- Note that once the previous number is modified, the subsequent numbers should also be operated with this new .
Here, denotes bitwise XOR.
- What is bitwise XOR?
- The bitwise XOR of non-negative integers and , , is defined as follows.
- When is written in base two, the digit in the 's place () is if exactly one of and is , and otherwise.
Input
The first line contains two integers .
The second line contains integers .
Output
Print the answer integers after operations, separated by spaces.
3 2
2 1 3
2 1 1
10 12
721939838 337089195 171851101 1069204754 348295925 77134863 839878205 89360649 838712948 918594427
721939838 337089195 171851101 1069204754 1069907851 277835428 942783328 988367899 624897153 844652404
Explanation
For the first sample, each operation changes as follows.
- Initially : .
- After the first operation :
- After the second operation: