ll find_left(ll x,ll y,ll val) {
if(v>val) return y+1; // where v is the min val in this node of the segtree.
if(s==e) return s;
if(x>m)return r->find_left(x,y,val);
else if(y<=m)return l->find_left(x,y,val);
else {
ll lv=l->find_left(x,m,val);
if(lv<=m) return lv;
else return r->find_left(m+1,y,val);
}
}
bGwgZmluZF9sZWZ0KGxsIHgsbGwgeSxsbCB2YWwpIHsKICAgIGlmKHY+dmFsKSByZXR1cm4geSsxOyAvLyB3aGVyZSB2IGlzIHRoZSBtaW4gdmFsIGluIHRoaXMgbm9kZSBvZiB0aGUgc2VndHJlZS4KICAgIGlmKHM9PWUpIHJldHVybiBzOwogICAgaWYoeD5tKXJldHVybiByLT5maW5kX2xlZnQoeCx5LHZhbCk7CiAgICBlbHNlIGlmKHk8PW0pcmV0dXJuIGwtPmZpbmRfbGVmdCh4LHksdmFsKTsKCWVsc2UgewoJICAgIGxsIGx2PWwtPmZpbmRfbGVmdCh4LG0sdmFsKTsKCQlpZihsdjw9bSkgcmV0dXJuIGx2OyAKCQllbHNlIHJldHVybiByLT5maW5kX2xlZnQobSsxLHksdmFsKTsKCX0gCn0=