#include <bits/stdc++.h>
using namespace std;
class FenwickTree {
vector<int> bit;
int n;
public:
FenwickTree(int size) : n(size), bit(size + 1, 0) {}
void update(int index, int delta) {
for (++index; index <= n; index += index & -index)
bit[index] += delta;
}
int query(int index) {
int sum = 0;
for (++index; index > 0; index -= index & -index)
sum += bit[index];
return sum;
}
int rangeQuery(int left, int right) {
return query(right) - query(left - 1);
}
};
int main() {
// your code goes here
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CgpjbGFzcyBGZW53aWNrVHJlZSB7CiAgICB2ZWN0b3I8aW50PiBiaXQ7CiAgICBpbnQgbjsKCnB1YmxpYzoKICAgIEZlbndpY2tUcmVlKGludCBzaXplKSA6IG4oc2l6ZSksIGJpdChzaXplICsgMSwgMCkge30KCiAgICB2b2lkIHVwZGF0ZShpbnQgaW5kZXgsIGludCBkZWx0YSkgewogICAgICAgIGZvciAoKytpbmRleDsgaW5kZXggPD0gbjsgaW5kZXggKz0gaW5kZXggJiAtaW5kZXgpCiAgICAgICAgICAgIGJpdFtpbmRleF0gKz0gZGVsdGE7CiAgICB9CgogICAgaW50IHF1ZXJ5KGludCBpbmRleCkgewogICAgICAgIGludCBzdW0gPSAwOwogICAgICAgIGZvciAoKytpbmRleDsgaW5kZXggPiAwOyBpbmRleCAtPSBpbmRleCAmIC1pbmRleCkKICAgICAgICAgICAgc3VtICs9IGJpdFtpbmRleF07CiAgICAgICAgcmV0dXJuIHN1bTsKICAgIH0KCiAgICBpbnQgcmFuZ2VRdWVyeShpbnQgbGVmdCwgaW50IHJpZ2h0KSB7CiAgICAgICAgcmV0dXJuIHF1ZXJ5KHJpZ2h0KSAtIHF1ZXJ5KGxlZnQgLSAxKTsKICAgIH0KfTsKCmludCBtYWluKCkgewoJLy8geW91ciBjb2RlIGdvZXMgaGVyZQoJcmV0dXJuIDA7Cn0=