#line 1 "ucup3-25/B/main.cpp"
#include <cstdint>
#define YOSUPO_AVX2_PRAGMA
// #undef YOSUPO_LOCAL
#line 2 "/home/vscode/yosupo-library/src/yosupo/fastio.hpp"
#include <unistd.h>
#include <algorithm>
#include <array>
#include <bit>
#include <cassert>
#include <cctype>
#line 10 "/home/vscode/yosupo-library/src/yosupo/fastio.hpp"
#include <cstring>
#include <sstream>
#include <string>
#include <type_traits>
#include <vector>
#line 2 "/home/vscode/yosupo-library/src/yosupo/internal_type_traits.hpp"
#line 5 "/home/vscode/yosupo-library/src/yosupo/internal_type_traits.hpp"
namespace yosupo {
namespace internal {
template <class T>
using is_signed_int128 =
typename std::conditional<std::is_same<T, __int128_t>::value ||
std::is_same<T, __int128>::value,
std::true_type,
std::false_type>::type;
template <class T>
using is_unsigned_int128 =
typename std::conditional<std::is_same<T, __uint128_t>::value ||
std::is_same<T, unsigned __int128>::value,
std::true_type,
std::false_type>::type;
template <class T>
using make_unsigned_int128 =
typename std::conditional<std::is_same<T, __int128_t>::value,
__uint128_t,
unsigned __int128>;
template <class T>
using is_integral =
typename std::conditional<std::is_integral<T>::value ||
internal::is_signed_int128<T>::value ||
internal::is_unsigned_int128<T>::value,
std::true_type,
std::false_type>::type;
template <class T>
using is_signed_int = typename std::conditional<(is_integral<T>::value &&
std::is_signed<T>::value) ||
is_signed_int128<T>::value,
std::true_type,
std::false_type>::type;
template <class T>
using is_unsigned_int =
typename std::conditional<(is_integral<T>::value &&
std::is_unsigned<T>::value) ||
is_unsigned_int128<T>::value,
std::true_type,
std::false_type>::type;
template <class T>
using to_unsigned = typename std::conditional<
is_signed_int128<T>::value,
make_unsigned_int128<T>,
typename std::conditional<std::is_signed<T>::value,
std::make_unsigned<T>,
std::common_type<T>>::type>::type;
template <class T>
using is_integral_t = std::enable_if_t<is_integral<T>::value>;
template <class T>
using is_signed_int_t = std::enable_if_t<is_signed_int<T>::value>;
template <class T>
using is_unsigned_int_t = std::enable_if_t<is_unsigned_int<T>::value>;
template <class T> using to_unsigned_t = typename to_unsigned<T>::type;
} // namespace internal
} // namespace yosupo
#line 17 "/home/vscode/yosupo-library/src/yosupo/fastio.hpp"
namespace yosupo {
struct Scanner {
public:
Scanner(const Scanner&) = delete;
Scanner& operator=(const Scanner&) = delete;
Scanner(FILE* fp) : fd(fileno(fp)) { line[0] = 127; }
void read() {}
template <class H, class... T> void read(H& h, T&... t) {
bool f = read_single(h);
assert(f);
read(t...);
}
int read_unsafe() { return 0; }
template <class H, class... T> int read_unsafe(H& h, T&... t) {
bool f = read_single(h);
if (!f) return 0;
return 1 + read_unsafe(t...);
}
int close() { return ::close(fd); }
private:
static constexpr int SIZE = 1 << 15;
int fd = -1;
std::array<char, SIZE + 1> line;
int st = 0, ed = 0;
bool eof = false;
bool read_single(std::string& ref) {
if (!skip_space()) return false;
ref = "";
while (true) {
char c = top();
if (c <= ' ') break;
ref += c;
st++;
}
return true;
}
bool read_single(double& ref) {
std::string s;
if (!read_single(s)) return false;
ref = std::stod(s);
return true;
}
template <class T,
std::enable_if_t<std::is_same<T, char>::value>* = nullptr>
bool read_single(T& ref) {
if (!skip_space<50>()) return false;
ref = top();
st++;
return true;
}
template <class T,
internal::is_signed_int_t<T>* = nullptr,
std::enable_if_t<!std::is_same<T, char>::value>* = nullptr>
bool read_single(T& sref) {
using U = internal::to_unsigned_t<T>;
if (!skip_space<50>()) return false;
bool neg = false;
if (line[st] == '-') {
neg = true;
st++;
}
U ref = 0;
do {
ref = 10 * ref + (line[st++] & 0x0f);
} while (line[st] >= '0');
sref = neg ? -ref : ref;
return true;
}
template <class U,
internal::is_unsigned_int_t<U>* = nullptr,
std::enable_if_t<!std::is_same<U, char>::value>* = nullptr>
bool read_single(U& ref) {
if (!skip_space<50>()) return false;
ref = 0;
do {
ref = 10 * ref + (line[st++] & 0x0f);
} while (line[st] >= '0');
return true;
}
bool reread() {
if (ed - st >= 50) return true;
if (st > SIZE / 2) {
std::memmove(line.data(), line.data() + st, ed - st);
ed -= st;
st = 0;
}
if (eof) return false;
auto u = ::read(fd, line.data() + ed, SIZE - ed);
if (u == 0) {
eof = true;
line[ed] = '\0';
u = 1;
}
ed += int(u);
line[ed] = char(127);
return true;
}
char top() {
if (st == ed) {
bool f = reread();
assert(f);
}
return line[st];
}
template <int TOKEN_LEN = 0> bool skip_space() {
while (true) {
while (line[st] <= ' ') st++;
if (ed - st > TOKEN_LEN) return true;
if (st > ed) st = ed;
for (auto i = st; i < ed; i++) {
if (line[i] <= ' ') return true;
}
if (!reread()) return false;
}
}
};
struct Printer {
public:
template <char sep = ' ', bool F = false> void write() {}
template <char sep = ' ', bool F = false, class H, class... T>
void write(const H& h, const T&... t) {
if (F) write_single(sep);
write_single(h);
write<true>(t...);
}
template <char sep = ' ', class... T> void writeln(const T&... t) {
write<sep>(t...);
write_single('\n');
}
Printer(FILE* _fp) : fd(fileno(_fp)) {}
~Printer() { flush(); }
int close() {
flush();
return ::close(fd);
}
void flush() {
if (pos) {
auto res = ::write(fd, line.data(), pos);
assert(res != -1);
pos = 0;
}
}
private:
static std::array<std::array<char, 2>, 100> small;
static std::array<unsigned long long, 20> tens;
static constexpr size_t SIZE = 1 << 15;
int fd;
std::array<char, SIZE> line;
size_t pos = 0;
std::stringstream ss;
template <class T,
std::enable_if_t<std::is_same<char, T>::value>* = nullptr>
void write_single(const T& val) {
if (pos == SIZE) flush();
line[pos++] = val;
}
template <class T,
internal::is_signed_int_t<T>* = nullptr,
std::enable_if_t<!std::is_same<char, T>::value>* = nullptr>
void write_single(const T& val) {
using U = internal::to_unsigned_t<T>;
if (val == 0) {
write_single('0');
return;
}
if (pos > SIZE - 50) flush();
U uval = val;
if (val < 0) {
write_single('-');
uval = -uval;
}
write_unsigned(uval);
}
template <class U,
internal::is_unsigned_int_t<U>* = nullptr,
std::enable_if_t<!std::is_same<char, U>::value>* = nullptr>
void write_single(U uval) {
if (uval == 0) {
write_single('0');
return;
}
if (pos > SIZE - 50) flush();
write_unsigned(uval);
}
static int calc_len(uint64_t x) {
int i = ((63 - std::countl_zero(x)) * 3 + 3) / 10;
if (x < tens[i])
return i;
else
return i + 1;
}
template <class U,
internal::is_unsigned_int_t<U>* = nullptr,
std::enable_if_t<2 >= sizeof(U)>* = nullptr>
void write_unsigned(U uval) {
size_t len = calc_len(uval);
pos += len;
char* ptr = line.data() + pos;
while (uval >= 100) {
ptr -= 2;
memcpy(ptr, small[uval % 100].data(), 2);
uval /= 100;
}
if (uval >= 10) {
memcpy(ptr - 2, small[uval].data(), 2);
} else {
*(ptr - 1) = char('0' + uval);
}
}
template <class U,
internal::is_unsigned_int_t<U>* = nullptr,
std::enable_if_t<4 == sizeof(U)>* = nullptr>
void write_unsigned(U uval) {
std::array<char, 8> buf;
memcpy(buf.data() + 6, small[uval % 100].data(), 2);
memcpy(buf.data() + 4, small[uval / 100 % 100].data(), 2);
memcpy(buf.data() + 2, small[uval / 10000 % 100].data(), 2);
memcpy(buf.data() + 0, small[uval / 1000000 % 100].data(), 2);
if (uval >= 100000000) {
if (uval >= 1000000000) {
memcpy(line.data() + pos, small[uval / 100000000 % 100].data(),
2);
pos += 2;
} else {
line[pos] = char('0' + uval / 100000000);
pos++;
}
memcpy(line.data() + pos, buf.data(), 8);
pos += 8;
} else {
size_t len = calc_len(uval);
memcpy(line.data() + pos, buf.data() + (8 - len), len);
pos += len;
}
}
template <class U,
internal::is_unsigned_int_t<U>* = nullptr,
std::enable_if_t<8 == sizeof(U)>* = nullptr>
void write_unsigned(U uval) {
size_t len = calc_len(uval);
pos += len;
char* ptr = line.data() + pos;
while (uval >= 100) {
ptr -= 2;
memcpy(ptr, small[uval % 100].data(), 2);
uval /= 100;
}
if (uval >= 10) {
memcpy(ptr - 2, small[uval].data(), 2);
} else {
*(ptr - 1) = char('0' + uval);
}
}
template <
class U,
std::enable_if_t<internal::is_unsigned_int128<U>::value>* = nullptr>
void write_unsigned(U uval) {
static std::array<char, 50> buf;
size_t len = 0;
while (uval > 0) {
buf[len++] = char((uval % 10) + '0');
uval /= 10;
}
std::reverse(buf.begin(), buf.begin() + len);
memcpy(line.data() + pos, buf.data(), len);
pos += len;
}
void write_single(const std::string& s) {
for (char c : s) write_single(c);
}
void write_single(const char* s) {
size_t len = strlen(s);
for (size_t i = 0; i < len; i++) write_single(s[i]);
}
template <class T> void write_single(const std::vector<T>& val) {
auto n = val.size();
for (size_t i = 0; i < n; i++) {
if (i) write_single(' ');
write_single(val[i]);
}
}
};
inline std::array<std::array<char, 2>, 100> Printer::small = [] {
std::array<std::array<char, 2>, 100> table;
for (int i = 0; i <= 99; i++) {
table[i][1] = char('0' + (i % 10));
table[i][0] = char('0' + (i / 10 % 10));
}
return table;
}();
inline std::array<unsigned long long, 20> Printer::tens = [] {
std::array<unsigned long long, 20> table;
for (int i = 0; i < 20; i++) {
table[i] = 1;
for (int j = 0; j < i; j++) {
table[i] *= 10;
}
}
return table;
}();
} // namespace yosupo
#line 2 "/home/vscode/yosupo-library/src/yosupo/fastset.hpp"
#line 8 "/home/vscode/yosupo-library/src/yosupo/fastset.hpp"
namespace yosupo {
struct FastSet {
static constexpr int B = 64;
// bool配列a_0, a_1, ..., a_nを作る
explicit FastSet(int n) : _n(n) {
do {
seg.push_back(std::vector<uint64_t>((n + B - 1) / B));
n = (n + B - 1) / B;
} while (n > 1);
_log = int(seg.size());
}
// bool配列a_0, a_1, ..., a_nを作る
explicit FastSet(int n, std::vector<uint64_t> v) : _n(n) {
{
int n2 = (n + B - 1) / B;
seg.push_back(v); //std::vector<uint64_t>(n2));
// for (int i = 0; i < n; i++) {
// if (v[i]) seg[0][i / B] |= 1ULL << (i % B);
// }
n = n2;
}
while (n > 1) {
int n2 = (n + B - 1) / B;
std::vector<uint64_t> v2(n2);
for (int i = 0; i < n; i++) {
if (seg.back()[i]) {
v2[i / B] |= 1ULL << (i % B);
}
}
seg.push_back(std::move(v2));
n = n2;
}
_log = int(seg.size());
}
// a[i]を返す。a[i] = falseは出来ないことに注意(要検討)
bool operator[](int i) const { return (seg[0][i / B] >> (i % B) & 1) != 0; }
// a[i] = true
void set(int i) {
for (int h = 0; h < _log; h++) {
seg[h][i / B] |= 1ULL << (i % B);
i /= B;
}
}
// a[i] = false
void reset(int i) {
for (int h = 0; h < _log; h++) {
seg[h][i / B] &= ~(1ULL << (i % B));
if (seg[h][i / B]) break;
i /= B;
}
}
// @return i以上最小の要素 or n
int or_more(int i) const {
if (i >= _n) return _n;
i = std::max(i, 0);
for (int h = 0; h < _log; h++) {
if (i / B == int(seg[h].size())) break;
uint64_t d = seg[h][i / B] >> (i % B);
if (!d) {
i = i / B + 1;
continue;
}
// find
i += std::countr_zero(d);
for (int g = h - 1; g >= 0; g--) {
i *= B;
i += std::countr_zero(seg[g][i / B]);
}
assert((*this)[i]);
return i;
}
return _n;
}
// @return iより大きい最小の要素 or n
int more(int i) const {
if (i >= _n - 1) return _n;
return or_more(i + 1);
}
// @return i以下最大の要素 or -1
int or_less(int i) const {
if (i < 0) return -1;
i = std::min(i, _n - 1);
for (int h = 0; h < _log; h++) {
if (i == -1) break;
uint64_t d = seg[h][i / B] << (63 - i % 64);
if (!d) {
i = i / B - 1;
continue;
}
// find
i -= std::countl_zero(d);
for (int g = h - 1; g >= 0; g--) {
i *= B;
i += B - 1 - std::countl_zero(seg[g][i / B]);
}
return i;
}
return -1;
}
// @return iより小さい最大の要素 or -1
int less(int i) const {
if (i <= 0) return -1;
return or_less(i - 1);
}
private:
int _n, _log;
std::vector<std::vector<uint64_t>> seg;
};
} // namespace yosupo
#line 2 "/home/vscode/yosupo-library/src/yosupo/random.hpp"
#line 6 "/home/vscode/yosupo-library/src/yosupo/random.hpp"
#include <chrono>
#line 8 "/home/vscode/yosupo-library/src/yosupo/random.hpp"
#include <random>
#line 10 "/home/vscode/yosupo-library/src/yosupo/random.hpp"
namespace yosupo {
struct Xoshiro256StarStar {
public:
using result_type = uint64_t;
Xoshiro256StarStar() : Xoshiro256StarStar(0) {}
explicit Xoshiro256StarStar(uint64_t seed) {
// use splitmix64
// Reference: http://xoshiro.di.unimi.it/splitmix64.c
for (int i = 0; i < 4; i++) {
uint64_t z = (seed += 0x9e3779b97f4a7c15);
z = (z ^ (z >> 30)) * 0xbf58476d1ce4e5b9;
z = (z ^ (z >> 27)) * 0x94d049bb133111eb;
s[i] = z ^ (z >> 31);
}
}
static constexpr result_type min() { return 0; }
static constexpr result_type max() { return -1; }
result_type operator()() {
const uint64_t result_starstar = rotl(s[1] * 5, 7) * 9;
const uint64_t t = s[1] << 17;
s[2] ^= s[0];
s[3] ^= s[1];
s[1] ^= s[2];
s[0] ^= s[3];
s[2] ^= t;
s[3] = rotl(s[3], 45);
return result_starstar;
}
private:
// Use xoshiro256**
// Refereces: http://xoshiro.di.unimi.it/xoshiro256starstar.c
static uint64_t rotl(const uint64_t x, int k) {
return (x << k) | (x >> (64 - k));
}
std::array<uint64_t, 4> s;
};
// https://github.com/wangyi-fudan/wyhash
struct WYRand {
public:
using result_type = uint64_t;
explicit WYRand(uint64_t seed) : s(seed) {}
static constexpr result_type min() { return 0; }
static constexpr result_type max() { return -1; }
result_type operator()() {
s += 0x2d358dccaa6c78a5;
auto x = (unsigned __int128)s * (s ^ 0x8bb84b93962eacc9);
return (uint64_t)(x ^ (x >> 64));
}
private:
uint64_t s;
};
using Random = WYRand;
inline Random& global_gen() {
static Random gen(
std::chrono::steady_clock::now().time_since_epoch().count());
return gen;
}
template <class G>
concept random_64 = std::uniform_random_bit_generator<G> &&
std::same_as<uint64_t, std::invoke_result_t<G&>> &&
G::min() == uint64_t(0) && G::max() == uint64_t(-1);
namespace internal {
// random choice from [0, upper]
template <random_64 G> uint64_t uniform_u64(uint64_t upper, G& gen) {
if (!(upper & (upper + 1))) {
// b = 00..0011..11
return gen() & upper;
}
int log = 63 - std::countl_zero(upper);
uint64_t mask = (log == 63) ? ~0ULL : (1ULL << (log + 1)) - 1;
while (true) {
uint64_t r = gen() & mask;
if (r <= upper) return r;
}
}
// random choice from [0, upper], faster than uniform_u64
template <random_64 G> uint64_t random_u64(uint64_t upper, G& gen) {
return (uint64_t)(((unsigned __int128)(upper) + 1) * gen() >> 64);
}
} // namespace internal
template <class T, random_64 G> T uniform(T lower, T upper, G& gen) {
return T(lower +
internal::uniform_u64(uint64_t(upper) - uint64_t(lower), gen));
}
template <class T> T uniform(T lower, T upper) {
return uniform(lower, upper, global_gen());
}
template <class T, random_64 G> T random(T lower, T upper, G& gen) {
return T(lower +
internal::random_u64(uint64_t(upper) - uint64_t(lower), gen));
}
template <class T> T random(T lower, T upper) {
return random(lower, upper, global_gen());
}
template <random_64 G> bool uniform_bool(G& gen) { return gen() & 1; }
inline bool uniform_bool() { return uniform_bool(global_gen()); }
// select 2 elements from [lower, uppper]
template <class T, random_64 G>
std::pair<T, T> uniform_pair(T lower, T upper, G& gen) {
assert(upper - lower >= 1);
T a, b;
do {
a = uniform(lower, upper, gen);
b = uniform(lower, upper, gen);
} while (a == b);
if (a > b) std::swap(a, b);
return {a, b};
}
template <class T> std::pair<T, T> uniform_pair(T lower, T upper) {
return uniform_pair(lower, upper, global_gen());
}
// random value in the interval (0.0, 1.0]
template <class G> inline double open_closed_01(G& gen) {
union {
uint64_t i;
double f;
} u = {0xbff0000000000000 | (gen() >> 12)};
return 2.0 + u.f;
}
inline double open_closed_01() {
return open_closed_01(global_gen());
}
} // namespace yosupo
#line 8 "ucup3-25/B/main.cpp"
using namespace yosupo;
#line 2 "ucup3-25/B/base.hpp"
#ifdef YOSUPO_AVX2_PRAGMA
#line 5 "ucup3-25/B/base.hpp"
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
#endif
#line 11 "ucup3-25/B/base.hpp"
#include <bitset>
#line 13 "ucup3-25/B/base.hpp"
#include <cmath>
#include <cstdio>
#line 16 "ucup3-25/B/base.hpp"
#include <iostream>
#include <map>
#include <queue>
#include <ranges>
#include <set>
#line 22 "ucup3-25/B/base.hpp"
#include <utility>
#line 24 "ucup3-25/B/base.hpp"
using std::abs, std::pow, std::sqrt;
using std::array, std::vector, std::string, std::queue, std::deque;
using std::countl_zero, std::countl_one, std::countr_zero, std::countr_one;
using std::istream, std::ostream, std::cerr, std::endl;
using std::min, std::max, std::swap;
using std::pair, std::tuple, std::bitset;
using std::popcount;
using std::priority_queue, std::set, std::multiset, std::map;
using std::views::iota, std::views::reverse;
namespace ranges = std::ranges;
using ranges::sort, ranges::copy_n;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); }
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
#ifdef YOSUPO_LOCAL
inline ostream& operator<<(ostream& os, __int128_t x) {
if (x < 0) {
os << "-";
x *= -1;
}
if (x == 0) {
return os << "0";
}
string s;
while (x) {
s += char(x % 10 + '0');
x /= 10;
}
ranges::reverse(s);
return os << s;
}
inline ostream& operator<<(ostream& os, __uint128_t x) {
if (x == 0) {
return os << "0";
}
string s;
while (x) {
s += char(x % 10 + '0');
x /= 10;
}
ranges::reverse(s);
return os << s;
}
template <class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p);
template <class T> ostream& operator<<(ostream& os, const V<T>& v);
template <class T> ostream& operator<<(ostream& os, const deque<T>& v);
template <class T, size_t N>
ostream& operator<<(ostream& os, const array<T, N>& a);
template <class T> ostream& operator<<(ostream& os, const set<T>& s);
template <class T, class U>
ostream& operator<<(ostream& os, const map<T, U>& m);
template <class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
return os << "P(" << p.first << ", " << p.second << ")";
}
template <class T> ostream& operator<<(ostream& os, const V<T>& v) {
os << "[";
bool f = false;
for (auto d : v) {
if (f) os << ", ";
f = true;
os << d;
}
return os << "]";
}
template <class T> ostream& operator<<(ostream& os, const deque<T>& v) {
os << "[";
bool f = false;
for (auto d : v) {
if (f) os << ", ";
f = true;
os << d;
}
return os << "]";
}
template <class T, size_t N>
ostream& operator<<(ostream& os, const array<T, N>& a) {
os << "[";
bool f = false;
for (auto d : a) {
if (f) os << ", ";
f = true;
os << d;
}
return os << "]";
}
template <class T> ostream& operator<<(ostream& os, const set<T>& s) {
os << "{";
bool f = false;
for (auto d : s) {
if (f) os << ", ";
f = true;
os << d;
}
return os << "}";
}
template <class T> ostream& operator<<(ostream& os, const multiset<T>& s) {
os << "{";
bool f = false;
for (auto d : s) {
if (f) os << ", ";
f = true;
os << d;
}
return os << "}";
}
template <class T, class U>
ostream& operator<<(ostream& os, const map<T, U>& s) {
os << "{";
bool f = false;
for (auto p : s) {
if (f) os << ", ";
f = true;
os << p.first << ": " << p.second;
}
return os << "}";
}
struct PrettyOS {
ostream& os;
bool first;
template <class T> auto operator<<(T&& x) {
if (!first) os << ", ";
first = false;
os << x;
return *this;
}
};
template <class... T> void dbg0(T&&... t) {
(PrettyOS{cerr, true} << ... << t);
}
#define dbg(...) \
do { \
cerr << __LINE__ << " : " << #__VA_ARGS__ << " = "; \
dbg0(__VA_ARGS__); \
cerr << endl; \
} while (false);
#else
#define dbg(...)
#endif
#line 11 "ucup3-25/B/main.cpp"
Scanner sc = Scanner(stdin);
Printer pr = Printer(stdout);
int main() {
int n, q;
sc.read(n, q);
//n = TEN(6);
//q = TEN(6);
// 01-reversed
V<FastSet> s0, s1;
auto set = [&](int i, ull x) {
for (int j : iota(0, 63)) {
if ((x >> j) & 1) {
s0[j].reset(i);
s1[j].set(i);
} else {
s0[j].set(i);
s1[j].reset(i);
}
}
};
if (true) {
int n2 = (n + 63) / 64;
VV<uint64_t> v0(63, V<uint64_t>(n2));
VV<uint64_t> v1(63, V<uint64_t>(n2));
for (int i : iota(0, n)) {
ull x;
sc.read(x);
//x = uniform(0ULL, -1ULL);
for (int j : iota(0, 63)) {
if ((x >> j) & 1) {
v1[j][i / 64] |= 1ULL << (i % 64);
} else {
v0[j][i / 64] |= 1ULL << (i % 64);
}
}
}
for (int i : iota(0, 63)) {
s0.emplace_back(n, std::move(v0[i]));
s1.emplace_back(n, std::move(v1[i]));
}
} else {
for (int _ : iota(0, 63)) {
s0.emplace_back(n);
s1.emplace_back(n);
}
for (int i : iota(0, n)) {
ull x = uniform(0ULL, -1ULL);
set(i, x);
}
}
for (int _ : iota(0, q)) {
int t;
sc.read(t);
//t = uniform(1, 3);
if (t == 1) {
int l, r;
ull x;
sc.read(l, r, x);
l--;
//std::tie(l, r) = uniform_pair(0, n);
//x = uniform(0ULL, -1ULL);
for (int j : iota(0, 63)) {
if ((x >> j) & 1) continue;
int i = l;
while (true) {
i = s1[j].or_more(i);
if (i >= r) break;
s1[j].reset(i);
s0[j].set(i);
}
}
} else if (t == 2) {
int i;
ull x;
sc.read(i, x);
i--;
//i = uniform(0, n - 1);
//x = uniform(0ULL, -1ULL);
// x = -1ULL;
set(i, x);
} else if (t == 3) {
int l, r;
sc.read(l, r);
l--;
//std::tie(l, r) = uniform_pair(0, n);
ull ans = 0;
int p = -1;
for (int j : iota(0, 63) | reverse) {
ans <<= 1;
int i0 = s0[j].or_more(l);
if (i0 >= r) {
// all 1
ans |= 1;
continue;
}
if (p != -1 && p != i0) {
// different 0
continue;
}
int i1 = s0[j].more(i0);
if (i1 < r) {
// two 0s
continue;
}
p = i0;
ans |= 1;
}
pr.writeln(ans);
} else {
assert(false);
}
}
return 0;
}