## GUPTA MECHANICAL

IN THIS WEBSITE I CAN TELL ALL ABOUT TECH. TIPS AND TRICKS APP REVIEWS AND UNBOXINGS ALSO TECH. NEWS .............

## [Solution] NIT orz! Codeforces Solution | Codeforces Problem Solution 2022

A. NIT orz!
time limit per test
1 second
memory limit per test
512 megabytes
input
standard input
output
standard output

NIT, the cleaver, is new in town! Thousands of people line up to orz him. To keep his orzers entertained, NIT decided to let them solve the following problem related to $\mathrm{or}z$. Can you solve this problem too?

You are given a 1-indexed array of $n$ integers, $a$, and an integer $z$. You can do the following operation any number (possibly zero) of times:

• Select a positive integer $i$ such that $1\le i\le n$. Then, simutaneously set ${a}_{i}$ to $\left({a}_{i}\mathrm{or}z\right)$ and set $z$ to $\left({a}_{i}\mathrm{and}z\right)$. In other words, let $x$ and $y$ respectively be the current values of ${a}_{i}$ and $z$. Then set ${a}_{i}$ to $\left(x\mathrm{or}y\right)$ and set $z$ to $\left(x\mathrm{and}y\right)$.

Here $\mathrm{or}$ and $\mathrm{and}$ denote the bitwise operations OR and AND respectively.

Solution Click Below:-  👉
👇👇👇👇👇

Find the maximum possible value of the maximum value in $a$ after any number (possibly zero) of operations.

Input
Each test contains multiple test cases. The first line contains the number of test cases $t$ ($1\le t\le 100$). Description of the test cases follows.

The first line of each test case contains two integers $n$ and $z$ ($1\le n\le 2000$$0\le z<{2}^{30}$).

The second line of each test case contains $n$ integers ${a}_{1}$,${a}_{2}$,$\dots$,${a}_{n}$ ($0\le {a}_{i}<{2}^{30}$).

It is guaranteed that the sum of $n$ over all test cases does not exceed ${10}^{4}$.

Output

For each test case, print one integer — the answer to the problem.