template<typename T, const int M = sizeof(T) * 8>
struct Liner_Basis {
T a[M];
size_t sz;
Liner_Basis() : a(), sz() {}
size_t size() const {
return sz;
}
void clear() {
memset(a, 0, sizeof a);
}
bool ins(T x) {
for (size_t i = M - 1; ~i && x; --i)
if (x >> i & 1) {
if (a[i]) x ^= a[i];
else return a[i] = x, true;
}
return false;
}
Liner_Basis& operator+=(const Liner_Basis&_) {
for (T x : _.a) if (x) this->ins(x);
return *this;
}
Liner_Basis operator+(const Liner_Basis&_) {
Liner_Basis z = *this;
return z += _;
}
T qry(T x = 0) {
for (size_t i = M - 1; ~i; --i)
if ((x ^ a[i]) > x) x ^= a[i];
return x;
}
};
template<typename T>
using LB = Liner_Basis<T>;