XrkArul And Bitwise Operations

TimeLimit:1000MS  MemoryLimit:256MB
64-bit integer IO format:%lld
未提交 | 登录后收藏
Problem Description

XrkArul has finished learning bitwise operations and he wants to do some practice. He finds an array a of length n, and intends to perform Q bitwise operations. Each operation is given as follows:


AND x. XrkArul change ai to (ai & x) for each i ∈ [1,n].


OR x. XrkArul change ai to (ai | x) for each i ∈ [1,n].


XOR x. XrkArul change ai to (ai ^ x) for each i ∈ [1,n].


Now XrkArul has quickly calculated the answers, and he wants to verify whether his answer is correct. Please help him.

Input

The first line contains two integers n,Q  ( 1 ≤ n,Q ≤ 3e5 ).


The second line contains n integers a1,a2,...,an  (0 ≤  ai  ≤ 230−1).


Then,Q lines follow. Each line contains a string OP (OP∈{AND,OR,XOR}) and an integer x (0 ≤ x ≤ 230−1).

Output

Print a single line contains n integers. The result of array a after doing Q bitwise operations.

SampleInput
5 3
1 2 3 4 5
AND 3
OR 5
XOR 6
SampleOutput
3 1 1 3 3
Submit
题目统计信息详细
总AC数23
通过人数13
尝试人数15
总提交量73
AC率17.81%
AC该题后可以添加标签
贴完标签可以获得20ACB。
并且可以获得本题所有提交代码查看权限。
点击标题可以显示标签。
如果你还没认真思考过这题,请不要查看标签
如果您已经通过了该题,请务为该题贴上标签

T^T Online Judge

[BUG反馈] [FAQ] [闽ICP备17026590号-1]
当前版本:3.24 系统时间: