#include #include #include #include #include using namespace std; using ll=long long; #define all(v) v.begin(),v.end() #define rall(v) v.rbegin(),v.rend() template bool chmax(T &a, T b){if (a < b){a = b;return true;} else return false;} template bool chmin(T &a, T b){if (a > b){a = b;return true;} else return false;} template struct dual_segment_tree { using F = typename O::T; public: explicit dual_segment_tree() {} explicit dual_segment_tree(int N) : dual_segment_tree(std::vector(N)) {} explicit dual_segment_tree(const std::vector& v) { int N = (int)v.size(); n = N; size = 1; log = 0; while (size < N) { size <<= 1; log++; } data.resize(N); lazy.resize(size, O::e()); for (int i = 0; i < N; i++) data[i] = v[i]; }; void set(int p, T x) { assert(0 <= p && p < n); push_from_root(p + size); data[p] = x; } T get(int p) { assert(0 <= p && p < n); push_from_root(p + size); return data[p]; } void apply(int p, F f) { assert(0 <= p && p < n); push_from_root(p + size); data[p] = mapping(f, data[p]); } void apply(int l, int r, F f) { assert(0 <= l && l <= r && r <= n); if (l == r) return; l += size; r += size; for (int i = log; i >= 1; i--) { if (((l >> i) << i) != l) push(l >> i); if (((r >> i) << i) != r) push((r - 1) >> i); } while (l < r) { if (l & 1) all_apply(l++, f); if (r & 1) all_apply(--r, f); l >>= 1; r >>= 1; } } private: int n, size, log; std::vector data; std::vector lazy; void all_apply(int k, F f) { if (k >= size) { if (k - size < n) data[k - size] = mapping(f, data[k - size]); } else { lazy[k] = O::op(f, lazy[k]); } } void push(int p) { assert(0 <= p && p < size); all_apply(2 * p, lazy[p]); all_apply(2 * p + 1, lazy[p]); lazy[p] = O::e(); } void push_from_root(int p) { for (int i = log; i >= 1; i--) push(p >> i); } }; using Tp=int; const Tp ID=1<<30; struct O{ using T=int; static T op(T l,T r){return(l==ID?r:l);} static T e(){return ID;} }; Tp mapping(O::T f,Tp x){return(f==ID?x:f);} int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); int N,A; cin>>N>>A; vectorX(N); vectorV; for(int i=0;i>X[i]; V.push_back(X[i]); } int T; cin>>T; vectorL(T),R(T); for(int i=0;i>L[i]>>R[i]; V.push_back(L[i]); V.push_back(R[i]); } sort(all(V)); V.erase(unique(all(V)),V.end()); int l=V.size(); mapmp; for(int i=0;iseg(l); for(int i=0;i