#include using namespace std; using ll=long long; namespace Lib { template struct segtree { int size, _n; vector seg; segtree(int n) { _n = n; size = 1; while (size < n) size <<= 1; seg = vector(size * 2, e()); } void set(int p, S val) { p += size; seg[p] = val; while (p /= 2) { seg[p] = op(seg[p * 2], seg[p * 2 + 1]); } } S prod(int l, int r) { S retL = e(), retR = e(); for (l += size, r += size; l < r; l /= 2, r /= 2) { if (l % 2) retL = op(retL, seg[l++]); if (r % 2) retR = op(seg[--r], retR); } return op(retL, retR); } S get(int p) { return seg[p + size]; } template int max_right(int L, F f) { L += size; S sm = e(); do { while (L % 2 == 0) L /= 2; if (!f(op(sm, seg[L]))) { while (L < size) { L *= 2; if (f(op(sm, seg[L]))) { sm = op(sm, seg[L]); L++; } } return L - size; } sm = op(sm, seg[L]); L++; } while ((L & -L) != L); return _n; } template int min_left(int R, F f) { R += size; S sm = e(); do { R--; while (R > 1 && R % 2 == 1) R /= 2; if (!f(op(seg[R], sm))) { while (R < size) { R = R * 2 + 1; if (f(op(seg[R], sm))) { sm = op(seg[R], sm); R--; } } return R + 1 - size; } sm = op(seg[R], sm); } while ((R & -R) != R); return 0; } }; } // namespace Lib int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); int N,M; ll K; cin>>N>>M>>K; vector C(N,0),A(M,0); for(int &i:C)cin>>i,--i; for(int &i:A)cin>>i; auto seg_op=[](ll a,ll b){ return min(a,b); }; auto seg_e=[](){ return (ll)1e18; }; Lib::segtree seg(M); for(int i=0;i